• 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

classpath

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
crispy bacon. crispy tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic