Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
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
Subject
Written By
Posted
September 02, 2005 03:08AM
November 28, 2005 06:25AM
December 16, 2005 11:45AM
December 16, 2005 12:13PM
September 10, 2009 11:15AM
September 10, 2009 11:32AM
September 25, 2007 04:22PM
September 05, 2011 07:07AM
February 12, 2010 11:00PM
December 03, 2010 10:52AM
September 28, 2007 04:20AM
November 29, 2007 04:01PM
September 26, 2011 02:08AM
Re: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
May 06, 2007 03:15PM
November 13, 2007 04:05PM
November 30, 2007 11:56AM
February 06, 2008 02:03AM
December 14, 2008 08:25PM
September 03, 2009 07:37AM
December 04, 2009 08:15AM
November 08, 2010 01:11PM
February 21, 2011 04:32AM