*
The moose likes JDBC and the fly likes JDBC & My SQL connection Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC & My SQL connection Problem" Watch "JDBC & My SQL connection Problem" New topic
Author

JDBC & My SQL connection Problem

Scott Farran
Greenhorn

Joined: Mar 10, 2002
Posts: 9
Hi,
This may be a simple thing I am overlooking so thanks in advance for any help. I am trying to connect to a mySQL database through a servlet that is called from a html form submission. I have all the connection properties in a simple class and when I try to instantiate the class, I get this error.....
java.lang.ClassNotFoundException: org.gjt.mm.mysql.Driver
now the first thing I did was assume that I had the classpath set-up wrong. So I re-did it and it still failed. So I create a simple class in the main method all i do create an instance of the same object that is failing my servlet. ANd you know what?? It works fine, the connection is established no problem. So I know that the classpath is set OK, but I can't understand why it would work in one spot and not in the other. Does it have something to do with being called from a servlet?? I am so frustrated here.
Any Ideas???
Scott, scjp
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The first thing I would mention is that you may be using an old JDBC Driver for MySQL. That is not your problem per say, but you will want to download the latest Driver called Connector/J from here
The next thing is org.gjt.mm.mysql.Driver you will want to change to com.mysql.jdbc.Driver. That is the new Driver class used with Connector/J.
As for your problem what I would like you to try or make sure of is that you have your JDBC Driver in the appropriate location. You should have a lib folder under your WEB-INF folder of your web app. This is where you will want to put all libraries your web app may be accessing. Including your JDBC Driver.
Try that, and then let us know if this was the case or not.


GenRocket - Experts at Building Test Data
Scott Farran
Greenhorn

Joined: Mar 10, 2002
Posts: 9
Thanks Gregg,
That did it!! I moved the driver to the lib folder and re-set the path. Everything is fine now thanks!!
-Scott
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

No problem. Happy to help.
I only know the answer because I made the same mistakes along the way.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC & My SQL connection Problem
 
Similar Threads
URGENT HELP NEEDED
HelloWorldServlet in Weblogic 6.0
one servlet question
jar niggles
jsp cant call bean in websphere