Hello, I've been banging my metaphorically banging my head again the wall all day attempting to use a simple servlet to connect to a db2 database and update a table. I eventually run into the Exception you see above.
I've read a couple of other forum posts from various forums and as far as I can tell I have eveything in order:
- My classpath is: .;C:\Program Files\SQLLIB\bi n;C:\ServletDev ;C:\tomcat 4.1\common\lib\ servlet.jar;C:\ Program Files\SQLLIB\ja va\db2java.zip; C:\jdk1.3.1_08\ bin;C:\ServletD ev; which I believe incorporates all of the directories I need.
- I have placed the db2java.zip file containing the proper driver in about every lib directory I could find in my tomcat folders
- I can make a connection to a database when I am not using a servlet.
- My servlets do run properly when I am not trying to connect to a database.
Here is the code for the helper class to my servlet file:
public class DatabaseUtil
{
public static void updateDatabase( String ID, String name)
throws ClassNotFoundEx ception, SQLException
{
Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver ");
Connection con = DriverManager.g etConnection("j dbc:db2:java");
Statement stmt = con.createState ment();
String upString = "INSERT INTO Surtable VALUES ('" + ID + "', '" +
name + "')";
stmt.executeUpd ate(upString);
stmt.close();
con.close();
}
}
The same using oracle with ojdbc14.jar works fine with appropriate change in code.
But for db2 it does not!!!!!!! Please help
Any suggestions would be appreciated.
I've read a couple of other forum posts from various forums and as far as I can tell I have eveything in order:
- My classpath is: .;C:\Program Files\SQLLIB\bi n;C:\ServletDev ;C:\tomcat 4.1\common\lib\ servlet.jar;C:\ Program Files\SQLLIB\ja va\db2java.zip; C:\jdk1.3.1_08\ bin;C:\ServletD ev; which I believe incorporates all of the directories I need.
- I have placed the db2java.zip file containing the proper driver in about every lib directory I could find in my tomcat folders
- I can make a connection to a database when I am not using a servlet.
- My servlets do run properly when I am not trying to connect to a database.
Here is the code for the helper class to my servlet file:
public class DatabaseUtil
{
public static void updateDatabase( String ID, String name)
throws ClassNotFoundEx ception, SQLException
{
Class.forName(" COM.ibm.db2.jdb c.app.DB2Driver ");
Connection con = DriverManager.g etConnection("j dbc:db2:java");
Statement stmt = con.createState ment();
String upString = "INSERT INTO Surtable VALUES ('" + ID + "', '" +
name + "')";
stmt.executeUpd ate(upString);
stmt.close();
con.close();
}
}
The same using oracle with ojdbc14.jar works fine with appropriate change in code.
But for db2 it does not!!!!!!! Please help
Any suggestions would be appreciated.
Comment