Unable to load jdbc driver eclipse

Tags: , ,

I get the following error while trying to load MySQL Driver:

  java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:171)
      at amazon.category.database.MerchantAdoptionStats.main(MerchantAdoptionStats.java:96)

Th relevant code is:

try {
    Class.forName("com.mysql.jdbc.Driver");   //line 96
    //Some more code
} catch (ClassNotFoundException ex) {

I am using eclipse and here are the settings(please see the added jar in classpath):

enter image description here

What else am I missing?

EDIT: Run time configrations:

enter image description here


You have included mysql jdbc drivers in build path of your project, which is not same as runtime path.

Check your runtime classpath by going to Run -> Run Configurations and select your application configuration. Check the classpath setting there.

Source: stackoverflow