Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

error oracle.jdbc.driver does not exist

Status
Not open for further replies.

lhugh

MIS
May 21, 2000
115
CA
I got this error

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\khoa\org\apache\jsp\MainOracleConnection_jsp.java:62: package oracle.jdbc.driver does not exist
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());


However, I can run the pretty same code through netbeans without any error, which means that my oracle driver exist. What do I need to do to fix this problem?

Thanks
 
Tip : having spaces in your tomcat (and all java) applications will only cause problems at some point due to problems using the ClassLoader and a misunderstanding by most people of how the ClassLoader uses directory paths.
Always use an install dir with no spaces.

Also understand that the JVM uses the CLASSPATH environment variable to locate the resources it needs to run an application. In most cases, tomcat will ignore the CLASSPATH and load its own, in order to avoid class confliction.

To resolve your problem, add classes12.jar into the directory TOMCAT_HOME/common/lib . Be sure NOT to add classes12.zip because a bug in tomcat 5 means it will not load zip files, only jar files.

Finally, the best way to get a connection (if you are not using connection pooling) is this :


Code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" +host+":" +port +":" +SID, user, password);

You do not need to explictly register the driver yourself because the code :

Class.forName("oracle.jdbc.driver.OracleDriver");

does this for you, so you will be registering two driver instances with the DriverManager, which could create further problems. All JDBC compliant drivers have a static initializer which registers the class with the DriverManager when you create the Class (note not object instance) using the above code.
 
To lhugh,

I am trying to connect to an ORACLE database using the thin driver using the Netbeans IDE. I have downloaded the classes12.zip file and mounted it. But when I run the program I get an error that the Oracledriver is not found. I want to know how do I set the classpath in Netbeans so that I can add classes12.zip to the classpath. I am unable to find a way to set the classpath in Netbeans. I can see that the bootstrap.jar and tools.jar are found in the classpath, but they must have been already set by Netbeans, how do I add an extra path to the classpath.

Thanks
 
I have mounted the archive classes12.jar in Netbeans and I can see the file structure of oracle\jdbc\driver\oracledrive on the left hand side in the filesystems tab. But when I debug the program I get an exception at Class.forName ("oracle.jdbc.driver.oracledriver");
It says cannot find the source mounted on the filesystem.
What could be wrong ?

Thanks
 
Its :

oracle.jdbc.driver.OracleDriver

not :

oracle.jdbc.driver.oracledriver

Java class names are case sensitive.
 
thalak

did you get everything to work?

if you can not complile using NetBeans, try to compile your project straight from the command line (using javac and java) I was not able to get my NetBeans to work with the Oracle thin driver, however, I was able to compile my project from the command line



 
I have not tried from the command line, but have been trying with Netbeans. I was under the assumption that I have not done some settings properly. But whatever I try, I get the same error. For another example, it gave javax.servlet.http does not exist. I mounted the servlet.jar file and still it gives the error. Anyway, I will try both the examples from the command line and let you know. I had downloaded JBoss with tomcat embedded and that does not have servlet.jar anywhere. So I have been trying the same example with Netbeans.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top