• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This should be easy but the obvious CLASSPATH thing isn't working.

I'm on a linux system. I've got a java program that wants to access a MySQL database. If the code is relevant to the problem I can post it.

The code compiles fine.

When I try to run it I get this:



I set my CLASSPATH like this:



And, I believe that Driver.class should be accessible to java:



What am I missing? Yes, it's an ancient jar file but that shouldn't cause the error, I don't think.

Thanks.
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 36031
432
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For Java classpaths, you need to specify the jar (or a wildcard) and not just the directory. The directory can only be specified for loose class files. Try adding this to your classpath:
/app/tomcat/lib/mysql-connector-java-3.1.12-bin.jar
 
Stan Lederer
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jeanne Boyarsky wrote:For Java classpaths, you need to specify the jar (or a wildcard) and not just the directory. The directory can only be specified for loose class files. Try adding this to your classpath:
/app/tomcat/lib/mysql-connector-java-3.1.12-bin.jar

Thanks, Jeanne, I appreciate it. That did it.

 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!