Hi
I have done all the codings part for connecting mysql server with java application but when i try to compile,the compilation is successful and during execution i get the following message,
Exception in thread "main" java.lang.NoCla ssDefFoundError : MysqlConnect
Coding Part:
import java.sql.*;
import java.lang.*;
public class MysqlConnect{
public static void main(String[] args)throws SQLException {
System.out.prin tln("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql ://localhost:3306/";
String dbName = "customer";
String driver = "com.mysql.jdbc .Driver";
String userName = "root";
String password = "root";
try {
Class.forName(d river);
conn = DriverManager.g etConnection(ur l+dbName,userNa me,pa ssword);
System.out.prin tln("Connected to the database");
conn.close();
System.out.prin tln("Disconnect ed from database");
} catch (java.lang.Clas sNotFoundExcept ion e) {
//System.out.prin tln("Could not connect");
e.printStackTra ce();
}
}
}
Execution steps:
C:\PROGRA~1\Jav a\jdk1.6.0_01\b in>javac -classpath "c:\program files\java\jdk1 .6.
0_01\jre\lib\ex t\mysql-connector-5.0.7-bin.jar" MysqlConnect.ja va
C:\PROGRA~1\Jav a\jdk1.6.0_01\b in>java -classpath "c:\program files\java\jdk1 .6.0
_01\jre\lib\ext \mysql-connector-5.0.7-bin.jar" MysqlConnect
Result which i get is:
Exception in thread "main" java.lang.NoCla ssDefFoundError : MysqlConnect
I have specified the classpath clearly and i have the jar file of mysql driver in the location,
"c:\program files\java\jdk1 .6.0_01\jre\lib \ext\mysql-connector-5.0.7-bin.jar"
But still i get the same result as specified in execution part above.
I am too tired in finding out the solution.....
Urgent...Please help me to connect to mysql server.
I have done all the codings part for connecting mysql server with java application but when i try to compile,the compilation is successful and during execution i get the following message,
Exception in thread "main" java.lang.NoCla ssDefFoundError : MysqlConnect
Coding Part:
import java.sql.*;
import java.lang.*;
public class MysqlConnect{
public static void main(String[] args)throws SQLException {
System.out.prin tln("MySQL Connect Example.");
Connection conn = null;
String url = "jdbc:mysql ://localhost:3306/";
String dbName = "customer";
String driver = "com.mysql.jdbc .Driver";
String userName = "root";
String password = "root";
try {
Class.forName(d river);
conn = DriverManager.g etConnection(ur l+dbName,userNa me,pa ssword);
System.out.prin tln("Connected to the database");
conn.close();
System.out.prin tln("Disconnect ed from database");
} catch (java.lang.Clas sNotFoundExcept ion e) {
//System.out.prin tln("Could not connect");
e.printStackTra ce();
}
}
}
Execution steps:
C:\PROGRA~1\Jav a\jdk1.6.0_01\b in>javac -classpath "c:\program files\java\jdk1 .6.
0_01\jre\lib\ex t\mysql-connector-5.0.7-bin.jar" MysqlConnect.ja va
C:\PROGRA~1\Jav a\jdk1.6.0_01\b in>java -classpath "c:\program files\java\jdk1 .6.0
_01\jre\lib\ext \mysql-connector-5.0.7-bin.jar" MysqlConnect
Result which i get is:
Exception in thread "main" java.lang.NoCla ssDefFoundError : MysqlConnect
I have specified the classpath clearly and i have the jar file of mysql driver in the location,
"c:\program files\java\jdk1 .6.0_01\jre\lib \ext\mysql-connector-5.0.7-bin.jar"
But still i get the same result as specified in execution part above.
I am too tired in finding out the solution.....
Urgent...Please help me to connect to mysql server.
Comment