views:

288

answers:

3

I'm getting ClassNotFoundException on Class.forname("com.mysql.jdbc.Driver") I'm using Windows Vista 64-bit, Eclipse Galileo, GWT framework. I downloaded mysql-connector-java-5.1.6-bin, but what is the exact path I should put this file in? I'm getting this exception while I'm in gwt-projects, but in normal projects it works good. Any idea how that should be done?

A: 

Just put the JAR file in the runtime classpath of the application in question.

In case of a Servlet based webapplication, you normally put it in /WEB-INF/lib folder. It's by default covered by the webapp's runtime classpath.

BalusC
Im running this code in GWT server side, i added mysql-connector-java-5.1.6-bin to the /WEB-INF/lib for the project, i also restart my IDE but still not working
Mohammed_Q
Is it a `.zip` file? The download is provided as a `.zip`. You'll need to extract the `.zip` and put the included `.jar` file in the classpath. Also read the instructions at the download page...
BalusC
no..its .jar file im sure from the path, but always give me the same exception, i really tried a lot of solutions..but nothing works, thats really weird
Mohammed_Q
A: 

Disable Google App Engine. Its a setting in Eclipse.

Google App Engine doesn't allow you to open Sockets. When you try to load the JDBC driver, it makes a socket connection in a static block. An exception in the static block leads to a ClassNotFoundException, which is what you are seeing.

sri
i was disabling it, but still not working until i change the version for the mysql-connector-java..thanks anyway
Mohammed_Q
A: 

Finally its worked, the problem was not in the classpath, but from the .jar file itself, im using mysql-connector-java-5.1.6-bin which was not working, but when i tried mysql-connector-java-3.0.17-ga-bin everything works good, i hope to fix the new version soon anyway thanks BalusC for helping :)

Mohammed_Q
make this a comment under your question, or edit your question. then upvote or select balusc as the answer
Thorbjørn Ravn Andersen