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

Hello Friends,

You may have come across “java.lang.ClassNotFoundException: com.mysql.jdbc.Driver”¬†error/exception while working with java and JDBC. The error occurs mainly when we try to connect to the mySql database from our java code. The error message itself give the clear indication about what we are missing. It says that it is unable to find the Class – “com.mysql.jdbc.Driver”.

Now, this exception is mainly due to unavailability of the mysql-connector jar file which contains the required class which is missing while the compilation of the code. This jar file contains many other classes those are listed in the below table

What you need to do is, just add the mysql-connector-java jar file in the build path of your program and then run the program again. Your program will run and execute properly. You can download the jar from MySql download link.

Hope this will help you.


Nikhil Naoghare.

One thought on “Error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.