This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

classpath  RSS feed

 
Veronica Damian
Ranch Hand
Posts: 61
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!