I'm trying to set up a connection between my applet and my mysql server using jdbc
I added the jar mysql-connector-java-5.1.14-bin.jar to the project
then I used this code
public void databaseTesting(){
Connection con;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection( "jdbc:mysql://localhost:3306/test", "root","");
System.err.println("connected !");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM `test`.`test`;");
while (rs.next()) {
int A = rs.getInt("columnA");
int B = rs.getInt("columnB");
System.err.println("A "+A+" B "+B);
}
} catch (SQLException e) {
System.err.println("failed to connect");
} catch (InstantiationException e) {
System.err.println("InstantiationException");
} catch (IllegalAccessException e) {
System.err.println("IllegalAccessException");
} catch (ClassNotFoundException e) {
System.err.println("ClassNotFoundException");
}
}
and for some reason I keep getting ClassNotFoundException.
edit
the jar is added to the build path and appears in the Referenced Libraries.
the exception is thrown by
Class.forName("com.mysql.jdbc.Driver").newInstance();
Anybody got an idea why ?
Thanks in advance jason