This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Classpath to mysql-driver" Watch "Classpath to mysql-driver" New topic

Classpath to mysql-driver

Je Th

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

Je Th

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

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.

So much trouble in the world -- Bob Marley
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63350

Je Th, please contact me at
JDBC Forum Bartender

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

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:
subject: Classpath to mysql-driver
jQuery in Action, 3rd edition