File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Classpath to mysql-driver Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Classpath to mysql-driver" Watch "Classpath to mysql-driver" New topic
Author

Classpath to mysql-driver

Je Th
Greenhorn

Joined: Dec 03, 2003
Posts: 12
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

Joined: May 22, 2003
Posts: 108
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


SCJP 1.2, SCJP 5, SCBCD
Je Th
Greenhorn

Joined: Dec 03, 2003
Posts: 12
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

Joined: Dec 03, 2003
Posts: 1
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

Joined: Nov 06, 2000
Posts: 1510
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.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Je Th, please contact me at bear@javaranch.com.
thanks,
bear
JDBC Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Je Th
Greenhorn

Joined: Dec 03, 2003
Posts: 12
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Classpath to mysql-driver
 
Similar Threads
JDBC connection error
classpath JDBC driver
JDBC Driver connection
java jdbc
Please help me with Java connection to MySql