2017  Kodetalk | Feedback | Privacy Policy | Terms | About

JDBC ClassNotFoundException

I am trying to make a connection java with it. But I am getting an exception ClassNotFoundException com.mysql.jdbc.Driver

Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)


The zip you downloaded should contain a file named mysql-connector-java-5.0.8-bin.jar or similar. Version might be different. Check if it is present and check that it is directly in your classpath.

If that's correct, check that the classpath variable is not overwritten by something else. If the program manually executed do it the following way: java -cp "C:Program FilesJavajre6libextmysql-connector-java-5.0.8-bin.jar:." YourClassName

If you are using an IDE such as eclipse, check the build-path settings there. (In eclipse right click your project -> Properties -> Java Build Path -> Add external JARs and then supply the path of your connector...jar.

Answer is