• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another "com.mysql.jdbc.Driver" Connection problem

 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the
tutorial to learn more about the JDBC Drivers. I am getting the following errors:

Exception in thread "main" 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:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at de.vogella.mysql.first.MySQLAccess.readDataBase(MySQLAccess.java:21)
at de.vogella.mysql.first.test.Main.main(Main.java:8)


The code is



Where the problem is steming from:



Classpath: C:\mysql-connector-java-5.1.15
File: C:\mysql-connector-java-5.1.15\mysql-connector-java-5.1.15-bin.jar

Is there anyway to confirm the URL path within MySQL Workbench? This may be the issue.


 
Paul Clapham
Sheriff
Posts: 21155
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Preston Thornton wrote:Is there anyway to confirm the URL path within MySQL Workbench? This may be the issue.


I don't know the answer to that, but it isn't your problem. This exception:

Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver


means that the driver class can't be found. And that would be because you didn't put the jar containing the driver file into your classpath.

But you're not alone. Probably 10 percent of the questions in this forum are this question. So if the hint about the classpath isn't enough, I'm sure that somebody has explained how to set your classpath in detail, or at least posted a link to the tutorial, in one or more of those threads.
 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, I read about that in the search for similar issues. My classpath is as follows:



This is what is in that directory
mysql-connector-java-5.1.15-bin.jar


 
Paul Clapham
Sheriff
Posts: 21155
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your classpath is supposed to consist of directories (where Java will look for classes) and jar files (where Java will look for classes). Specify the jar file in your classpath if you want Java to use it (and you do).
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic