Hello Martin
You have not passed the userid and the password in
con = DriverManager.getConnection(jdbcURL);
This can be a reason.
Martin Kuhn <[EMAIL PROTECTED]> on 11/29/99 05:07:55 PM
Please respond to "A mailing list for discussion about Sun Microsystem's
Java Servlet API Technology."
<[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Vinod Kumar A/Chennai/HCLDELUXE)
Subject: Use of DB2
Hello!
I've problems using DB/2 in servlet context. I have
a class to read data from DB/2. When I run this class
as app it works fine. But when I try to use it in a servlet
I get an exception when I call getConnection:
Message: [IBM][JDBC Driver] CLI0600E Invalid connection handle or
connection is
closed. SQLSTATE=S1000 SQLState: S1000 ErrorCode: -99999
Can anybody help me?
My configuration:
Windows NT 4.0 - SP4
JDK1.2.2
JSDK 2.0
Apache 1.3.9
Source:
import java.sql.*;
public class MDBZugriff
{
static String jdbcDriver="COM.ibm.db2.jdbc.app.DB2Driver";
static String jdbcURL="jdbc:db2:merkur";
String res="";
public MDBZugriff()
{
try
{
Connection con = null;
Class.forName(jdbcDriver).newInstance();
con = DriverManager.getConnection(jdbcURL);
Statement stmt = con.createStatement();
ResultSet r = stmt.executeQuery("SELECT * from userid.partner");
int i=0;
while (r.next())
{
String a = r.getString(1);
String str = r.getString(2);
res+=a+" "+str+"\n";
if(++i>15)
break;
}
r.close();
stmt.close();
con.close();
}
catch (SQLException ex)
{
while (ex != null)
{
res+="Message: "
+ ex.getMessage ()+"\n";
res+="SQLState: "
+ ex.getSQLState ()+"\n";
res+="ErrorCode: "
+ ex.getErrorCode ()+"\n";
ex = ex.getNextException();
System.out.println("");
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
public String getRes()
{
return res;
}
static public void main(String[] args)
{
MDBZugriff d=new MDBZugriff();
System.out.println("res "+d.getRes());
System.exit(0);
}
}
TIA
Martin
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html