jQuery in Action, 2nd edition*
The moose likes Java in General and the fly likes Could not load driver: oracle.jdbc.driver. OracleDriver problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Could not load driver: oracle.jdbc.driver. OracleDriver problem" Watch "Could not load driver: oracle.jdbc.driver. OracleDriver problem" New topic

Could not load driver: oracle.jdbc.driver. OracleDriver problem

Hu Li

Joined: Sep 08, 2004
Posts: 3
Hi all,
I got a problem that I can not solve for a few days.
I created a simple Java class to test connection to an Oracle database. It worked fine as the code returned a 'connection successful' message. I then zipped up the file and save it on a disk. However when I unzipped the file and tried to run it with a Windows batch file I got the dreaded message 'Could not load driver: oracle.jdbc.driver.OracleDriver' .Below is the batch file:
set CLASSPATH=%JAVA_HOME%\lib\rt.jar;%JAVA_HOME%\lib\i18n.jar;%DEFAULT_HOME_HOME%\lib\classes12.zip;%DEFAULT_HOME_HOME%\lib
java -jar testConn.jar


I have checked and made sure all of the required files are in their proper directories. Let me know if you spot a problem...
Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
So, is the "could not load driver" message a polite version of a ClassNotFoundException? If that's the case then the JVM obviously can't find the driver class in your classpath. Is the driver in classes12.zip? You should really double-check. What's the idea of having ./lib on the classpath? Have you tried running with -classpath on the command line? Do you stil have your original before you put it on disk? Does that still work? If so have you tried to run a diff?

Anyway, I hope this gives you some ideas but I can't see any obvious reason why it isn't working for you.

Hu Li

Joined: Sep 08, 2004
Posts: 3
Thanks for the reply.
Yes all files are in their proper directories.
I have tried the following:
1) java -classpath java -classpath .;C:\classes12;C:\jbuilder9\jdk1.4\jre\lib\rt.jar;C:\jbuilder9\jdk1.4\jre\lib\i18n.jar;C:\jbuilder9\jdk1.4\jre\lib\sunrsasign.jar;C:\jbuilder9\jdk1.4\jre\lib\jsse.jar;C:\jbuilder9\jdk1.4\jre\lib\jce.jar;C:\jbuilder9\jdk1.4\jre\lib\charsets.jar;C:\jbuilder9\jdk1.4\jre\classes;C:\jbuilder9\jdk1.4\lib\tools.jar -jar testConn.jar

In jbuilder, I see this when I tried to run the application

C:\jbuilder9\jdk1.4\bin\javaw -classpath "D:\Documents and Settings\bwfxhhb\jbproject\TestConnection\classes;C:\classes12;C:\jbuilder9\jdk1.4\jre\lib\rt.jar;C:\jbuilder9\jdk1.4\jre\lib\i18n.jar;C:\jbuilder9\jdk1.4\jre\lib\sunrsasign.jar;C:\jbuilder9\jdk1.4\jre\lib\jsse.jar;C:\jbuilder9\jdk1.4\jre\lib\jce.jar;C:\jbuilder9\jdk1.4\jre\lib\charsets.jar;C:\jbuilder9\jdk1.4\jre\classes;C:\jbuilder9\jdk1.4\lib\tools.jar" com.****.test.ConnectionManager
Load of driver successful: oracle.jdbc.driver.OracleDriver

DBURL = jdbc racle:thin:@XXXXXXXX.com:1521 RSFMID1

Connection successful :jdbc racle:thin:@XXXXXXX.com:1521 RSFMID1

Do you see any problems?
Hu Li

Joined: Sep 08, 2004
Posts: 3
I finally got it to work

I put the classes12.jar in java_home/jre/lib/ext as per the following forum

Now the question is, why does it work?
Prashant Jain

Joined: Aug 19, 2004
Posts: 29

I have encountered the same issue while working with WSAD.In the available JREs I gave the path of where i had installed JDK1.3, yet I had to put the classes12.zip in the ext.

My guess is that when i run the program within WSAD, only /ext folder is searched.Perhaps Julian could clear the doubt for both of us.
What do you say Julian?

Prashant Jain
I agree. Here's the link: http://aspose.com/file-tools
subject: Could not load driver: oracle.jdbc.driver. OracleDriver problem
Similar Threads
What am I doing wrong when setting the paths?
TOMCAT: Problems in installation (windows98)
Java JAR connecting to DB
Problem starting Tomcat.
java.sql.SQLException: No suitable driver