Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training

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

Tutorials   
JDBC Video Tutorial: Create, Read, Update and Delete (CRUD) Operation examples JDBC Video tutorial - How to read Data from MySQL Database? JDBC Video tutorial - How to delete Data in a MySQL Database? Solving java.lang.ClassNotFoundException: com.mysql.jdbc.Driver exception JDBC Video tutorial - How to update Data in a MySQL Database? JDBC Video Tutorial- How to insert data into MySQL database table? JDBC Video Tutorial: How to download JDBC Driver for MySQL? JDBC Tutorial - Writing first JDBC example and running in Eclipse Java Cross Join MySQL Database Connectivity Example In Java Change Column Name in MySQL Java Mysql Connection Example JDBC ODBC Connection In Java ResultSet In Java Prepared Statement Example JdbcRowSet interface Java JdbcRowSet Example First Step towards JDBC! JDBC Training, Learn JDBC yourself Jdbc Get Column Names JDBC Example with MySQL JDBC Prepared Statement Update JDBC Prepared Statement Insert JDBC Prepared Statement Example JDBC Prepared statement Close JDBC Prepared Statement Addbatch JDBC Nested Resultset JDBC-Odbc Connection JDBC-Odbc Connectivity JDBC Insert Preparedstatement JDBC Insert Null JDBC Get Metadata JDBC Insert Record Jdbc Insert Statement JDBC Meta Data Get tables Jdbc Mysql Connection String Jdbc Mysql Connection Url JDBC Next Jdbc Get Connection JDBC Get Int JDBC Exception JDBC Get Row Count JDBC Functions JDBC Fetch JDBC Execute Update Example JDBC Execute Statement JDBC Execute Query JDBC Drive For Mysql JDBC Connectivity Code In Java JDBC connection timeout
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

Ads
 

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