kirkegaard
Technical User
Java throws the following exception when I try to run the code: Exception in thread "main" java.lang.NoClassDefFoundError: DBConnect
I don't know what the problem is. My classpath should be in order, since it doesn't have to point to anything else than the JDBC driver for MySQL to work right?
import java.sql.*;
public class DBConnect {
public static void main(String[] args) {
try {
Class.forName("org.gjt.mm.mysql.Driver"
String sourceURL = "jdbc:mysqlfyr.cs.auc.dk:3306:e1202";
String user = "xxxxxx";
String password = "xxxxxx";
Connection databaseConnection = DriverManager.getConnection(sourceURL, user, password);
System.out.println("Connection established"
databaseConnection.close();
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe);
}
catch (SQLException sqle) {
System.err.println(sqle);
}
}
}
I don't know what the problem is. My classpath should be in order, since it doesn't have to point to anything else than the JDBC driver for MySQL to work right?
import java.sql.*;
public class DBConnect {
public static void main(String[] args) {
try {
Class.forName("org.gjt.mm.mysql.Driver"
String sourceURL = "jdbc:mysqlfyr.cs.auc.dk:3306:e1202";
String user = "xxxxxx";
String password = "xxxxxx";
Connection databaseConnection = DriverManager.getConnection(sourceURL, user, password);
System.out.println("Connection established"
databaseConnection.close();
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe);
}
catch (SQLException sqle) {
System.err.println(sqle);
}
}
}