File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath

 
Veronica Damian
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1608
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Remove the jar from jre/lib. Place it somewhere more appropriate on your file system - not in your JRE installation.
 
Veronica Damian
Ranch Hand
Posts: 61
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic