This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "classpath" Watch "classpath" New topic
Author

classpath

Veronica Damian
Ranch Hand

Joined: Feb 04, 2006
Posts: 61
Hi, I'm trying to connect to db from a stand-alone class (have done it many times with Tomcat); so copied mysql-connector-java-3.1.6-bin.jar from Tomcat/common/lib to jre/lib and put it in the classpath at compile time, thus:

javac -classpath c:\j2sdk1.4.2_11\jre\lib\mysql-connector-java-3.1.6-bin.jar;. conn.java

compiles fine but at runtime get ClassNotFoundException: com.mysql.jdbc.Driver

why wouldn't it find com.mysql.jdbc.Driver? I know it's inside that connector jar I put in the classpath..


-v
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Remove the jar from jre/lib. Place it somewhere more appropriate on your file system - not in your JRE installation.


Tony Morris
Java Q&A (FAQ, Trivia)
Veronica Damian
Ranch Hand

Joined: Feb 04, 2006
Posts: 61
thank you.. I had also tried that before I posted my question.. thus:

javac -classpath mysql-connector-java-3.1.6-bin.jar;. conn.java

the jar & class conn are in same dir.. this compiles fine but when try to run it get exact same ClassNotFound error... it can't find com.mysql.jdbc.Driver; but it's there, I looked (this same package works fine in Tomcat, but now am trying to connect to db (MySQL server installed in my HD, to which I connect all the time from Tomcat) from outside Tomcat, from a stand-alone class; you can connect to a db from a stand-alone class, can't you? thank you very much..

-v
 
Consider Paul's rocket mass heater.
 
subject: classpath
 
Similar Threads
NoClassDefFoundError
problem with mysql connecton!
Cannot create JDBC driver
very new and very lost...
Connecting to a MySQL database