Skip to content

Unable to load jdbc driver eclipse

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

  java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
      at Method)
      at java.lang.ClassLoader.loadClass(
      at sun.misc.Launcher$AppClassLoader.loadClass(
      at java.lang.ClassLoader.loadClass(
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(
      at amazon.category.database.MerchantAdoptionStats.main(

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.