2

enter image description here

I am trying to create the run the following in java program, but i am getting this error.

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1332) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1166) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Unknown Source)

    try {
        Class.forName("com.mysql.jdbc.Driver");
    } catch (ClassNotFoundException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

in build path, i have added the mysql connector jar file

javailike
  • 247
  • 1
  • 4
  • 13
  • Can you show your .classpath code whether the lib is pointing or not – murthy Jan 24 '17 at 11:16
  • 1
    As we can see in your screenshot, you have added it to the lib folder, but not to the classpath – Jens Jan 24 '17 at 11:17
  • @murthy can you tell me, where can i find the .classpath code – javailike Jan 24 '17 at 11:26
  • ... i think you should do tutorials for programming beginners first - theres no use in trying to do programming without proper knowledge about the subject, you will only fail if you do it – specializt Jan 24 '17 at 11:56

1 Answers1

2

In Eclipse, right-click on the project and select Build Path -> Configure Build Path. Select the Libraries tab, then the Add Jars button. Then select the MySQL jar file as shown in your project. Then press OK then OK. It should now work.

Steve Smith
  • 2,244
  • 2
  • 18
  • 22