my dog learned polymorphism
The moose likes JDBC and Relational Databases and the fly likes MySQL driver not found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "MySQL driver not found" Watch "MySQL driver not found" New topic

MySQL driver not found

RajivAwadhesh kumar

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 Method)
at java.lang.ClassLoader.loadClass(
at sun.misc.Launcher$AppClassLoader.loadClass(
at java.lang.ClassLoader.loadClass(
at java.lang.ClassLoader.loadClassInternal(
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(
at com.rajiv.TestDB.readDataFromDB(
at com.rajiv.TestDB.main(

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

Joined: Oct 14, 2005
Posts: 19973

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

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.
subject: MySQL driver not found
It's not a secret anymore!