• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic