• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

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

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using the


http://www.vogella.de/articles/MySQLJava/article.html#jdbc

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.


 
Marshal
Posts: 24963
61
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
Marshal
Posts: 24963
61
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).
 
Just let me do the talking. Ahem ... so ... you see ... we have this tiny ad...
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!