File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes another stupid Oracle JDBC driver question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "another stupid Oracle JDBC driver question" Watch "another stupid Oracle JDBC driver question" New topic
Author

another stupid Oracle JDBC driver question

Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Hi folks,
I've got this problem and I've searched the archives and found that loads of people have asked this before, but even though I seem to be following the suggested solutions, (and the Oracle docs) I'm still getting the "No suitable Driver" error.
This is the code:

I've got my oracle zip files set in my CLASSPATH (this is NT) and I'm stopping and restarting Tomcat like mad, and I've double-checked for spelling mistakes.
The Oracle DB is on another machine and I access it fine through SQLPlus and other such software which also use the tnsnames.ora file.
Any help for a real dumbo? It must be an obvious error.
Regards
Adam
[ Edited by Dave to fix the ]
[This message has been edited by David O'Meara (edited December 10, 2001).]


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

The problem with Tomcat is that (essentially) it ignores your classpath and sets things up for itself, so you have to place the jar in the correct place rather than being able to put it anywhere and point to it with your classpath.
If you are using Tomcat 4, put it in either your [TOMCAT HOME]/common/lib or webapps/[CONTEXT]/web-inf/lib directories.
Pre- Tomcat 4 I think you can drop it in your [TOMCAT HOME]/lib directory.
Not 100% sure on all of the above but it should get you started...
Dave.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
OK, I tried that, and the error changed from "No suitable driver" to "class oracle.jdbc.driver.OracleDriver() not found."
I've tried out several variations to try to solve the situation but it hasn't worked. I'm suspicious of the following points:
(1) the Oracle drivers from their website are in a ZIP file - shouldn't it be a jar file for Tomcat?
(2) I am using sun.jdbc.rowset.CachedRowSet and I have no problems with it. Having the Oracle stuff in the same directory didn't help.
(3) I unpacked the zip into the tomcat/common/classes directory but it didn't help.
Could I be using the wrong driver? It's the class12.zip file from Oracle's website, and I'm using J2SE 1.4 beta 3 and Oracle 8.1.7
It's there in the zip file though.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
I followed Oracle's instructions and I made an NT environment variable
CLASSPATH=d:\oracle\ora81\jdbc\lib\classes12.zip;d:\oracle\ora81\jdbc\lib\nls_charset12.zip
and I also had to edit c:\tomcat\bin\catalina.bat (the main script for tomcat4) on about line 70. For reasons unknown, they import the NT CLASSPATH variable, but then overwrite it! To correct this I just put %CLASSPATH% on the end of the assignment, and it added instead of overwrote.
Then use
DriverManager.registerDriver(new Oracle.jdbc.driver.OracleDriver());

That worked.
It also works if you make the classes12.zip into a jar (not sure if it's totally necessary) and then stick it in the tomcat/common/lib directory and use
Class.forName("oracle.jdbc.driver.OracleDriver");
I don't understand why tomcat differentiates between CLASSPATH and the tomcat/common/lib directory as a location for the classes when using DriverManager.registerDriver() or Class.forName()
Any tomcat gurus out there?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Renaming the classes from .zip to .jar is the preferred solution (or so I believe)
There are several reasons Tomcat manages its own paths, and most of them have to do with ClassLoaders (java.lang.ClassLoaders are classes that load classes, but you'd have to read up on that, I'm certainly not covering it all in this Forum!)
Basically, if you have a bunch of classes loaded by a single ClassLoader, if you remove that ClassLoader instance you can dynamically unload the classes. This allows you to alter JSPs at runtime since they can be unloaded each time you change them rather than having to restart the engine.
Dave.
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Basically are you saying it's not recommended to alter Tomcat's tomcat.bat or catalina.bat file so that the NT classpath variable is accepted, rather than overwritten?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: another stupid Oracle JDBC driver question
 
Similar Threads
Rangarajan Balasubramanian
Oracle JDBC unable to get connection
JDBC:ODBC Oracle Connection
getting a CLOB value as a String object
Unable to establish a network connection