Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error registering a driver to mysql db when using Tomcat

 
kartik krishnan
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,

I dont know if this is a right forum for this topic. I have a web application deployed in tomcat. In the servlet, I am trying to register the "com.mysql.jdbc.Driver" using Class.forName, I am getting the following error

SEVERE: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1362)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1208)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:164)


But, when I run the unittest for the same, I get a sucessful connection instance com.mysql.jdbc.Connection@1acd47. I don't know what I am doing wrong.

Please help me here.

Thanks,

Karthik
 
Jan Cumps
Bartender
Posts: 2588
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Apache/Tomcat forum would be the right one.

Bbaseline is: you have to put the jdbc driver for MySQL into the correct tomcat directory. This depends on the version of tomcat you're using.

Go to http://tomcat.apache.org/.
Select Documentation for your version on the left side.
Select JDBC datasources.
Look for the sentence : copy the JDBC Driver's jar into
Copy your mysql jar there.

Regards, Jan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic