aspose file tools*
The moose likes JDBC and the fly likes Unable to Load the Driver! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to Load the Driver!" Watch "Unable to Load the Driver!" New topic
Author

Unable to Load the Driver!

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I am getting this error when i am loading the JDBC class driver code. The funny thing is the code was taken from a working JDBC code written compiled and run successfully. But now its throwing an error:
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
The code that throws the error is:
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
You should not use newInstance. You simply load the class once using Class.forName () so the static block runs doing whatever it is doing.

You obtain a Connection using the DriverManager.


JDBCSupport - An easy to use, light-weight JDBC framework -
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Even without newInstance() method its throwing the error. I first coded without it, then as it was throwing the error i added the newInstance() in the end to check!
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
well it's throwing a CNF error meaning that either the you got the wrong path to the driver or the jar is not in the classpath.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
I have the jar added in the classpath. The thing is i guess its something to do with Tomcat rather the jars and classpaths. I have made a post in the Tomcat section as well about this:
http://www.coderanch.com/t/476492/Tomcat/Tomcat-Throwing-java-lang-ClassNotFoundException
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Issue resolved.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Unable to Load the Driver!