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

This exception java.lang.ClassNotFoundException: com.mysql.jdbc.Driver occurs when there is not JDBC driver for MySQL in project.

Ads

In this video tutorial I will show you an Eclipse project which is throwing the java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception while running the example program.

I will also explain you how you can solve the exception, which is occurring at run-time and preventing your application to be executed.

In our example program following exception is thrown at the time of running of the application:

 

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at net.roseindia.jdbc.UpdateDataExample.main(UpdateDataExample.java:16)

As the error indicates there is a mi Visit the website http://dev.mysql.com/downloads/connector/j/ and you will find the link for downloading the JDBC Driver. ssing class and the JVM is not able to find the class com.mysql.jdbc.Driver. Our JDBC program is connecting the MySQL database and then updating the data, but due to unavailability of the driver it is throwing exception.

To solve this you solve the error you have to download the JDBC driver of MySQL and then install.

Here is the video tutorial that shows you how resolve the java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception.

Visit the website http://dev.mysql.com/downloads/connector/j/ and you will find the link for downloading the JDBC Driver. From here you can download the JDBC driver for MySQL. After downloading the driver unzip it and then copy the mysql-connector-java-5.1.35-bin.jar file in your Eclipse project.

It is better to create a new directory lib in your project and then copy the mysql-connector-java-5.1.35-bin.jar file there.

Then include the jar file in the "Libraries" of the "Java Build Path" in Eclipse IDE.

Complete process is explained in the Video Tutorial and you should check the video for complete details.

Check the video tutorial: JDBC Video Tutorial: How to download JDBC Driver for MySQL?

Check 100s of JDBC Tutorials in our JDBC programming tutorials section.

Advertisements

Ads
Share on Google+Share on Google+

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

Posted on: June 8, 2015 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Advertisements

 

Discuss: Solving java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0

Ads

 

Ads