Friday, April 15, 2011

This error occurs when the required JDBC driver file is not in the CLASSPATH. Also, if the driver name is not correct ClassNotFoundException occurs. To solve this problem, at first check the driver name; if the driver name is correct, do one of the followings as per requirement.

i) Add an entry for the driver file (mysql-connector-java-5.1.10.jar, for example) in the CLASSPATH variable.


ii) If you are not familiar with the CLASSPATH variable, place the mysql-connector-java-5.1.10.jar file in \jre\lib\ext folder in the JDK install directory (for example C:\Program Files\Java\jdk1.6.0_20\jre\lib\ext)


iii) If you are doing this in NetBeans or other IDEs, add MySQL JDBC Driver Library in the project.

If the above solutions do not work for you. Please comment below giving your code. I'll try to respond.


  1. Nice article , you have indeed covered topic in details with sample code, its indeed a topic which require a deeper understanding than many other java topics.

    How Classpath works in Java

  2. thank you for help this bug gives me headache..