This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JDBC and the fly likes unable to connect to mysql database from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "unable to connect to mysql database from JSP" Watch "unable to connect to mysql database from JSP" New topic
Author

unable to connect to mysql database from JSP

Joel Karimpil
Ranch Hand

Joined: Oct 04, 2004
Posts: 53
i have set the classpath of the driver ;
the filename is mysql-connector-java-3.1.0-alpha-bin.jar
i am using jakarta-tomcat as my web server

i get a driver class not found error
the driver i have specified is org.gjt.mm.mysql.Driver

plz help


Yours Truly,
Joel Karimpil
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Put mysql-connector-java-3.1.0-alpha-bin.jar in Tomcat's lib directory.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Joel Karimpil
Ranch Hand

Joined: Oct 04, 2004
Posts: 53
i searched and i found many lib directories.
which lib directory must i place it in?
Joel Karimpil
Ranch Hand

Joined: Oct 04, 2004
Posts: 53
also, has a driver version to be compatible with a db version ?
i mean if the db is a new version and if the driver is old, is it still fine?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Joel Karimpil:
i searched and i found many lib directories.
which lib directory must i place it in?


The real answer is 'it depends', although the short answer is that the best place is the <context>/WEB-INF/lib directory. The reason this is the best is that it gives the code the smallest scope within the app server.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Originally posted by Joel Karimpil:
also, has a driver version to be compatible with a db version ?
i mean if the db is a new version and if the driver is old, is it still fine?


More likely you have an old database version and a newer driver version, but they tend to be backwards-compatible and I've never had a problem with MySQL.
Joel Karimpil
Ranch Hand

Joined: Oct 04, 2004
Posts: 53
thanks,

after placing the driver in WEB-INF\lib and setting the classpath it's working pretty fine.
 
Consider Paul's rocket mass heater.
 
subject: unable to connect to mysql database from JSP