Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to Load the Driver!

 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code that throws the error is:
 
Sebastian Janisch
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Issue resolved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic