Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes mySQL driver problem jvm WindowsXP, tried everything!! - please help!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "mySQL driver problem jvm WindowsXP, tried everything!! - please help!!!" Watch "mySQL driver problem jvm WindowsXP, tried everything!! - please help!!!" New topic

mySQL driver problem jvm WindowsXP, tried everything!! - please help!!!

Jonathon Parenteau

Joined: Feb 15, 2004
Posts: 5
Thanks for looking at this post. I am a java newbie and thought I had things under control, however, guess not, and any of the postings that make sense have things I had already applied. I am using Windows XP and I am using the JVM and a simple class to test a mySQL connection.
I have downloaded the mysql-connector-java-3.0.10-stable-bin.jar and have place it in my c:\j2sdk1.4.2_03\jre\lib\ext\ location.
Here is my CLASSPATH environment variable value:
Are there other settings I must change? The main issue here is that it cannot seem to find the .jar!?!?! I am using the following code that other postings helped me with and I get the following stack trace:
Thanks so much for your help in advance!
* Created on Feb 15, 2004
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
package client;
import java.sql.*;

public class JDBCExample {
public static void main(String[] args) {
try {
} catch (Exception E) {
System.err.println("Unable to load driver.");
try {
Connection C = DriverManager.getConnection("jdbc:mysql://localhost:53345/mysql","root","13004433");
// or Connection C = DriverManager.getConnection("jdbc:mysql://","root","13004433");
// or Connection C = DriverManager.getConnection("jdbc:mysql://");
// or Connection C = DriverManager.getConnection("jdbc:mysql://localhost:53345/mysql?user=root&password=13004433");

// Replace the PORT number (53345 in this example) by the port number on which your MySQL demon is running,
// replace the DATABASENAME (mysql in this example) with your database name
// replace USER with your user name and PASSWORD with your password and
// use if that is where MySQL is running for you.
// In most case "localhost" will also work. See what you get if you run
// the SQL command "SELECT * FROM user" from the MySQL command line interface
// and use what you see under "Host".

Statement s=C.createStatement();
String sql="select * from user"; // Put your SQL statement here
ResultSet res=s.getResultSet();
if (res!=null) {
while( { //note MySql start with the index 1 as the first column
} catch (SQLException E) {
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());

Unable to load driver.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at$ Source)
at Method)
at Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at client.JDBCExample.main(
SQLException: No suitable driver
SQLState: 08001
VendorError: 0
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Hmm, seems like you have it right. Two things to check.
First, make sure your're running the java version you think you are (it's pretty rare to have multiple JVMs, but it's possible)
From the command prompt, type:
java -fullversion
This should give you something like java full version "1.4.2-b28", but the build number may be different.
Secondly, see if you can find the class from the command line. Type this:
javap com.mysql.jdbc.Driver
This command uses the CLASSPATH to locate the named class and report on it. I find this useful to test the CLASSPATH without using the java application.
If that fails, you can play with the the CLASSPATH till it works.
placing the jar in your c:\j2sdk1.4.2_03\jre\lib\ext directory should allow the 'java' command to pick up the jar without needing to add it to your classpath. I'm wondering if your JAR is corrupted. To test this, try opening the JAR as a ZIP. The easiest way to do this is to rename the file .zip instead of .jar and open it with a program like WinZip, but XP should allow you to explore the zip anyway. If this fails, the file is bad and you should try downloading it again.
Don't forget to rename it back to .jar before trying to use it!
Hope this helps.
Jonathon Parenteau

Joined: Feb 15, 2004
Posts: 5
Thanks for the information. Here are my initial resuls.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\>java -fullversion
java full version "1.4.2_03-b02"
C:\>javap com.mysql.jdbc.Driver
'javap' is not recognized as an internal or external command,
operable program or batch file.
** I guess this means that I will have to try the CLASSPATH? or does this just mean I am in the wrong location to run javap? Thanks in advance. Once I confirm this segment works, I will be checking the status of the file itself with the steps you gave. Thanks for your time. Please let me know about the javap.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

What is in your path? Looks like your path is to your c:\j2sdk1.4.2_03\jre\bin directory and not the c:\j2sdk1.4.2_03\bin directory. Not a problem, just run this instead and see what it returns.
c:\j2sdk1.4.2_03\bin\javap com.mysql.jdbc.Driver
Jonathon Parenteau

Joined: Feb 15, 2004
Posts: 5
OK, sorry, I was stupid not to realize that. Here is what I get. What does this mean? Obviously it is finding it... Why do I get the errors?
Thanks in advance. I will try to open the .jar file and see what happens, but I expect that we just proved it is ok.
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\>c:\j2sdk1.4.2_03\bin\javap com.mysql.jdbc.Driver
Compiled from ""
public class com.mysql.jdbc.Driver extends com.mysql.jdbc.NonRegisteringDriver{
public com.mysql.jdbc.Driver();
throws java/sql/SQLException
static {};
Jonathon Parenteau

Joined: Feb 15, 2004
Posts: 5
I have renamed the mysql-connector-java-3.0.10-stable-bin.jar file to a Zip Executable and it opens fine, displaying the 61 files inside it. Not sure. Does the item I included in the last post help. Maybe I have the file location wrong? Thanks.
Jason Steele
Ranch Hand

Joined: Apr 25, 2003
Posts: 100
You may have multiple installs of Java on your machine. Search for that.. If you do, copy your jar to the other lib\ext directory. If it is in this directory, then it will not need to be added to the classpath, as it will be seen automatically.

Good luck!

An egg is a chicken's house!
Jonathon Parenteau

Joined: Feb 15, 2004
Posts: 5
I did have a multiple install. All is good. Really appreciate your time. Lesson learned, check for a few things before jumping to the postings. Appreciate it.
Tim Tock

Joined: Jan 15, 2004
Posts: 15
hey, im having exactly the same problem, god knows what im doing wrong, ive put that jar file in the ext folder, no multiple copies of java running
keep gettin the error Error: could not find com.mysql.jdbc.Driver when i type the command javap com.mysql.jdbc.Driver
my path to that jar file is C:\Program Files\j2sdk_nb\j2sdk1.4.2\lib\ext
I think my classpaths are not set up correctly, my system variables looks like this:
D:\CC301;C:\Program Files\j2sdk_nb\j2sdk1.4.2\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar
and path one looks like this:
%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\j2sdk_nb\j2sdk1.4.2\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar
please please please help me, my uni projects has to be in in a few weeks, im stressing so much.
ps meant to say the java -fullversion command works fine and prints out the expected version as posted previously
[ February 19, 2004: Message edited by: Tim Tock ]
I agree. Here's the link:
subject: mySQL driver problem jvm WindowsXP, tried everything!! - please help!!!
It's not a secret anymore!