My GWT application does not seem to find mysql-connector-java-5.1.22-bin.jar. Im using the Google App Engine.
I have set the jar in Project->RIghtClick->Properties->Java Build Path->Libraries->mysql-connector-java-5.1.22-bin.jar. I also added the "MySQL JDBC Driver". The $CLASSPATH is set correctly too (i dont think it matters because Im running the application in Eclipse).
I have tested the same code on command line and it works like a charm.
$ java -cp ~/mysql-connector-java-5.1.22/mysql-connector-java-5.1.22-bin.jar:. JDBCExample
-------- MySQL JDBC Connection Testing ------------
MySQL JDBC Driver Registered!
You made it, take control your database now!
When I run the Web Application in Eclipse, I get this
Exception:
-------- MySQL JDBC Connection Testing ------------
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
ClassNotFound - Where is your MySQL JDBC Driver?com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at com.google.appengine.tools.development.IsolatedAppClassLoader.loadClass(IsolatedAppClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:186)
at com.startupweekend.server.GreetingServiceImpl.readDB(GreetingServiceImpl.java:65)
at com.startupweekend.server.GreetingServiceImpl.greetServer(GreetingServiceImpl.java:21)
Code:
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("ClassNotFound - Where is your MySQL JDBC Driver?" + e.getMessage());
e.printStackTrace();
return;
}