Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Classpath to mysql-driver

 
Je Th
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mange to connect to my MySQL after adding the "MySQL Connector/J 3.0 Driver". But it only worked using the Eclipse Editor (choosing the right jar-file in the "Run-section"). What I want to do is to install the driver in cmd. I tried to type "set CLASSPATH=C:\MySQL\mysql-connector-java-3.0.9-stable-bin.jar;%CLASSPATH%" in cmd but that didnt do it. I didnt get any error mesage, Im supose to add some line to code, like telling my application that I want to use the driver I have installed?
Thanks for yout time
 
Chris Brat
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dont know how confident you are in java so dont want to insult you by saying the obvious, but have you looked at including the jar file in your execution command ?
something like ...
java -cp .;c:\mydir\myDBDriver.jar MyApp
 
Je Th
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply! I havent tried the sollutions yet. But just to make sure, if you dont want to insult me, then dont. As simple as that. If I ask something basic, then I must be in basic stage of java. You have to start some where.
Thanks for your time!
 
Jay Arr
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have no idea why your CLASSPATH strategy isn't working. But have you tried copying that long-named jar file into the $JAVA_HOME\jre\lib\ext directory and leaving your CLASSPATH unchanged (i.e., from its original value)? I'm trying to remember where I read that the "ext" directory is where the Java interpreter finds "extension" classes, as distinct from "bootstrap" and "user" classes. Anyway, it seemed to work for me, not that I've done much with mySql.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct Jay...The java intepreter will find any jar files located in the jdk\jre\lib\ext\ folder. If the jar files are put somewhere else, the path has to be made known my setting the classpath. I do have my mySQL jar file, servlet.jar, etc. in the above location.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64827
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Je Th, please contact me at bear@javaranch.com.
thanks,
bear
JDBC Forum Bartender
 
Je Th
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied the jarfile to the \lib\ext directory so it works fine now. I will explore the CLASSPATH some other day when I got more time.
Thanks for your time!
Je Th
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic