wood burning stoves 2.0*
The moose likes JDBC and the fly likes MySQL driver not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MySQL driver not found" Watch "MySQL driver not found" New topic
Author

MySQL driver not found

RajivAwadhesh kumar
Greenhorn

Joined: May 20, 2011
Posts: 24



I am getting the following error when i execute the above code

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at com.rajiv.TestDB.readDataFromDB(TestDB.java:15)
at com.rajiv.TestDB.main(TestDB.java:10)


Please suggest why the above error is coming? where do i need to put the driver file for MySQL?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Well, as always when you get that error, the class in question can't be found in your classpath. So where should you put the driver's JAR file? In your classpath.
hemantha kumar k
Greenhorn

Joined: Apr 20, 2010
Posts: 27

add the mysql Connector jar in your class path it is going to solve your problem, if you are using the command prompt create the environment variable called "CLASSPATH" and set the value as the path of the mysql connector folder.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: MySQL driver not found