• 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

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

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:
c:\j2sdk1.4.2_03\lib\tools.jar;c:\j2sdk1.4.2_03\jre\lib\ext\mysql-connector-java-3.0.10-stable-bin.jar;
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 {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception E) {
System.err.println("Unable to load driver.");
E.printStackTrace();
}
try {
Connection C = DriverManager.getConnection("jdbc:mysql://localhost:53345/mysql","root","13004433");
// or Connection C = DriverManager.getConnection("jdbc:mysql://csci571.usc.edu:53345/mysql","root","13004433");
// or Connection C = DriverManager.getConnection("jdbc:mysql://csci571.usc.edu:53345/mysql?user=root&password=13004433");
// 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 csci571.usc.edu 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
s.execute(sql);
ResultSet res=s.getResultSet();
if (res!=null) {
while(res.next()) { //note MySql start with the index 1 as the first column
System.out.println("\n"+res.getString(1)+"\t"+res.getString(2));
}
}
} catch (SQLException E) {
System.out.println("SQLException: " + E.getMessage());
System.out.println("SQLState: " + E.getSQLState());
System.out.println("VendorError: " + E.getErrorCode());
}
}
}

STACK TRACE:
Unable to load driver.
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown 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(JDBCExample.java:14)
SQLException: No suitable driver
SQLState: 08001
VendorError: 0
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Now...
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.
Dave
 
Jonathon Parenteau
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Jonathon
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 "Driver.java"
public class com.mysql.jdbc.Driver extends com.mysql.jdbc.NonRegisteringDriver{
public com.mysql.jdbc.Driver();
throws java/sql/SQLException
static {};
}
 
Jonathon Parenteau
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Jonathon Parenteau
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Jon
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
Thanks
Tim
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic