This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes java.lang.ClassNotFoundException: com.mysql.jdbc.Driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" Watch "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" New topic
Author

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

anwar pasha
Greenhorn

Joined: Jun 10, 2008
Posts: 19
I am doing simple servlet and jdbc code to insert the data into database
when trying to insert the data i am getting below error ,
i have given mysql-connector.jar file in classpath still its comming the error
can help me please..........


java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1352)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1198)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DbCon.getConnection(DbCon.java:12)
at HelloAleemExample.doGet(HelloAleemExample.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at

.
..
.
.
.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Check the documentation of your application server (is it Tomcat?). There will be a topic on how to add jar files to the classpath of that application server.
Typically, you have to place the jar file in a specific directory.


OCUP UML fundamental and ITIL foundation
youtube channel
Mick Foley
Greenhorn

Joined: Mar 07, 2011
Posts: 4
If you are using Tomcat Web container, add your jar file under the WEB-INF/lib directory for your web application. Hope that works for you.


Never give up your goal
uday kantt
Greenhorn

Joined: May 05, 2011
Posts: 26

Hi
So it is looking for a class called Driver in the com.mysql.jdbc package. For this you need to add the mysql-connector-java-5.0.8-bin.jar file to the classpath. Then things work fine.

Thanks
 
Consider Paul's rocket mass heater.
 
subject: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
 
Similar Threads
java.lang.ClassFormatError: Incompatible magic value 13375 in class file mycontroller/ValidatorExc
web service call from servlet :getting following error
JEuclid Class not found Error
need help with design of a Login page in JSP
Error : java.lang.ClassFormatError: Incompatible magic value 13375 in class file