It's not a secret anymore!
The moose likes JDBC and Relational Databases 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
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" Watch "java.lang.ClassNotFoundException: com.mysql.jdbc.Driver" New topic

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

anwar pasha

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(
at org.apache.catalina.loader.WebappClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at DbCon.getConnection(
at HelloAleemExample.doGet(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(

Jan Cumps

Joined: Dec 20, 2006
Posts: 2565

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
Mick Foley

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

Joined: May 05, 2011
Posts: 26

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.

I agree. Here's the link:
subject: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
It's not a secret anymore!