File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL driver not found

 
RajivAwadhesh kumar
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



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
Sheriff
Pie
Posts: 20166
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
Hibernate Java jQuery
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic