473,947 Members | 15,438 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ClassNotFoundEx ception- while using DB2Driver

7 New Member
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.
Jul 3 '07 #1
2 2158
r035198x
13,262 MVP
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.
If you use the same connection strings successfully when not using servlets, then the problem is a classpath problem...
Jul 3 '07 #2
jeffbroodwar
118 New Member
Hi,

Are you sure it's a .zip file? can you check the contents of that file... try if you can find a .jar file instead then paste it in your classpath.... it should work....


Best Regards,
Jeff
Jul 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
10864
by: Fu Bo Xia | last post by:
the java.lang.Object.forName method takes a java class name and returns a Class object associated with that class. eg. Class myClass = Object.forName("java.lang.String"); by if i only know the absolute file name of a .class file eg. C:\myJava\myApp.java, then how do i translate this file name to a java class name the Object.forName method would accept has it's parameter? thanks,
1
2613
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
1
3541
by: David Liebtag | last post by:
I have what I hope is a simple question: I'm learning how to serialize objects. I create an ObjectOutputStream and writeObject an object to it. I then create an ObjectInputStream and try to readObject the object from it. readObject is failing with a ClassNotFoundException. The class mentioned in the exception description is in a JAR file listed in CLASSPATH. I know the class can be found because I successfully create an object from...
0
2024
by: schwarcz | last post by:
I'm trying to resurrect some of my old RMI code and running into problems where the bind() throws a ClassNotFoundException for the remote interface. The old code ran on a older JDK and an older version of Windows. Any help you could offer would be GREATLY appreciated. I'm running on Windows XP Pro with 5.0 of the JDK. I've done my best to turn off any firewall, ani-virus, and Internet worm (Norton) checking. I've tried to reduce it a...
1
7096
by: Anoniem | last post by:
Hi, I'm trying to start a example which comes with the midp2.0 distribution. My relevant environment variables are set in a batch file like: PATH=%PATH%;\j2sdk1.4.2_10\bin;c:\j2me\midp2.0fcs\bin;j2me\j2me_cldc\bin set CLASSPATH=c:\j2me\midp2.0fcs\classes;. set MIDP_HOME=c:\j2me\midp2.0fcs When I go to the C:\j2me\midp2.0fcs\example directory and give the following
1
2811
by: nithiya sri | last post by:
i am new to struts.I try running struts application in Eclipse with the tomcat plug in .. it shows the following error:; please help me in this... SEVERE: Error loading WebappClassLoader delegate: false repositories:
8
6192
oll3i
by: oll3i | last post by:
it worked but suddenly when i run it and click a button it throws exception ? D:\SR>java Producent queue1 queue2 queue3 queue4 queue1,queue2,queue3,queue4 javax.naming.NoInitialContextException: Cannot instantiate class: org.exolab.jms .jndi.InitialContextFactory at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6 57) at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288 )
2
1318
by: pradeep84 | last post by:
Hi to all....... i hav compiled my program.. i got error like this java.lang.ClassNotFoundException: sun.jdbc.odbc.Jdbc.OdbcDriver can any one wat does it mean and how to resolve it.... regards pradeep
2
2973
by: inetjack | last post by:
Hi, This is a little test application, generating and compiling code at runtime. The loadClassLoader() method of the Factory Object suppose to unload all class previously loaded. It does not work!!! Somebody knows why?
1
3068
by: manjava | last post by:
Hello, i have a class java conncet to database mysql when i execute the classe alone so execute but when i want to execute this link on web :http://localhost:8080/ProjetService/services/Magasin/getMagasins i done this error: echec pilote :java.lang.ClassNotFoundException: com.mysql.jdbc.Driver echec connection a la bdd :java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/boutiquegeographique erreur...
0
10162
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9982
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11566
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
11153
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10689
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7428
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6113
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6331
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3541
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.