MySQL Forums
Forum List  »  Microsoft SQL Server

Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
Posted by: Vincent Hughitt
Date: May 06, 2007 03:15PM

Hi, I'm also having similar trouble and was hoping someone might be able to help. I have some code that i have working under linux, but cannot get to run under windows XP. Here is my config:

[Setup]

Windows Xp
Mysql 5.037
jdk 1.6 update 1

[CLASSPATH]

C:\>echo %CLASSPATH%
.;"C:\Program Files\Java\jdk1.6.0_01\lib";"C:\Program Files\Java\jdk1.6.0_01\lib
\mysql-connector-java-5.0.5-bin.jar"

[JDBC Driver]

(located as specified in classpath variable, and also in /jre/lib/ and /jre/lib/ext/ folders for each jdk installation).

[Code to run]

// Simple.java
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.ResultSet;

public class Simple {
public static void main(String[] args) {
Connection conn = null;

try {
Class.forName ("com.mysql.jdbc.Driver ");
conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/test", "javauser", "javapass");

// Do something with the Connection

}
catch (Exception ex) {/** do nothing */}
.
.
.

}
};


[ Compiling and Execution ]

//file located at C:
C:\>javac Simple.java

C:\>java Simple
ClassNotFoundException: com.mysql.jdbc.Driver
Exception in thread "main" java.lang.NullPointerException
at Simple.main(Simple.java:39)


I'm clueless now as to how to get this to work. I've Tried:
- Reinstalling the JDK
- Using -cp and -classpath to specify where to find the .jar file
- Adding quotation marks to CLASSPATH variable for directories with spaces
- Compiling and making using java and javac 1.5
- '' '' for 1.6
- Restarting
- Adding "newInstance();" to the problematic line
- Running from inside netbeans

and a few other things.. nothing seems to work. Anyone have any clues?

Also:

two things i noticed that i wasn't sure if relevent:

1) java and javac versions are different:

C:\>javac -version
javac 1.5.0_07
javac no source files

C:\>java -version
java version "1.6.0_01"
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

2) there is no JAVA_HOME environmental variable set

That's about it..

Any help would be greatly appreciated.
Thanks!
Keith

Options: ReplyQuote


Subject
Written By
Posted
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
May 06, 2007 03:15PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.