I've been working on this for weeks, and now I'm just running in circles. I'm getting the runtime error: " class not found exception in [class] while getting connection com.mysql.jdbc.Driver ".
The connection function is as follows:
/**
* @return a MySQL connection to the server as specified above
*/
private static Connection getConnection() {
Connection con = null;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
System.err.println("class not found exception in [class] while getting connection " + e.getMessage());
} catch (SQLException e) {
System.err.println("sql exception in [class] while getting connection " + e.getMessage());
}
return con;
} //end getConnection
I have set the $CLASSPATH
a hundred times a hundred ways, and still no luck. This is what it looks like now:
# echo $CLASSPATH
:/usr/share/java/mysql-connector-java-5.1.13-bin.jar:/usr/share/java/mysql-connector-java-3.0.17-ga-bin.jar:
Both of those files exist and have the Driver.class file in them in the right place.
I even tried importing the class into my code before exporting the jar, but that caused a world of other problems.
I'm using Eclipse 3.5.2 and the server is running Fedora 13 x86_64
Please help.
edit: I'm running the code remotely on my server with the command:
# java -jar program.jar