Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • 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
Marshal
Posts: 35279
384
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic