Failure in loading JDBC driver
Posted by: abdennad
Date: May 04, 2005 04:58PM

Hi:

I tried to run the following piece of code but it failed to load the JDBC
driver and generated an exception.

--------------------------- JAVA CODE -----------------------

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class mysqltest {
public static void main(String[] args) {
try {

// Load the driver
Class.forName("com.mysql.jdbc.Driver").newInstance();

} catch (Exception ex) {
// handle the error
System.out.println("main: Exception: " + ex.getCause() );
}
}

}

----------------------------------------------------------------

1- First I compiled it as follows:

D:\javatest\mysqltest>javac -classpath mysql-connector-java-3.1.8-bin.jar mysqltest.java

2 - Then I run it without the debugger as follows:

D:\javatest\mysqltest>java -classpath mysql-connector-java-3.1.8-bin.jar mysqltestcls

and I got this output on the console:

Exception in thread "main" java.lang.NoClassDefFoundError: mysqltest


3 - Then I run it through the debugger as follows:

D:\javatest\mysqltest>jdb -classpath mysql-connector-java-3.1.8-bin.jar mysqltest

and I got this output on the console:

Initializing jdb ...
> run
run mysqltest
Set uncaught java.lang.Throwable
Set deferred uncaught java.lang.Throwable
>
VM Started:
Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.net.URLClassLoader$1.run(), line=200 bci=72

main[1] cont
>
Exception occurred: java.lang.ClassNotFoundException (uncaught)"thread=main", java.net.URLClassLoader.findClass(), line=205 bci=28

main[1] cont
> java.lang.NoClassDefFoundError: mysqltest
Exception in thread "main"
The application exited

D:\javatest\mysqltest>


Do you have any idea what is going on and how I can interpret the errors

I am running the tests and compilations on a laptop with XP Pro SP2, JDBC 3.1.8

Thank you,

Akram.

Options: ReplyQuote


Subject
Written By
Posted
Failure in loading JDBC driver
May 04, 2005 04:58PM


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.