aspose file tools*
The moose likes Tomcat and the fly likes Error registering a driver to mysql db when using Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Error registering a driver to mysql db when using Tomcat" Watch "Error registering a driver to mysql db when using Tomcat" New topic
Author

Error registering a driver to mysql db when using Tomcat

kartik krishnan
Ranch Hand

Joined: Nov 19, 2006
Posts: 63
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

Joined: Dec 20, 2006
Posts: 2510
    
  10

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


OCUP UML fundamental and ITIL foundation
youtube channel
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error registering a driver to mysql db when using Tomcat