File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes problem with JSP connection & MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "problem with JSP connection & MySQL" Watch "problem with JSP connection & MySQL" New topic
Author

problem with JSP connection & MySQL

Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
I have an existing mysql install set up for php dev that I am trying to access with JSP.
Server is "localhost" with db name "fame"
user is "root" with pass "test"
I have added localhost.localdomain to my hosts file
The code I am using is:

The db fields are from my db instead of the test.
At first I was getting an error about not finding the driver for the connection. After a few hours on the net I found a mysql-connector-java.jar from the mysql site that I put in my WEB-INF/lib folder. Now I am getting a different error.

root cause
javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver"

I cannot seem to figure out why I can't get this to work and my goodness this is getting frustrating. I was stuck for a while because te jstl library files from the book have different taglib lines and now the mysql driver from jstl just won't work without all this extra hunting around. I am wondering does this much change in JSP in a year?
Thanks for the help.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Hmm. The error you're seeing is usually due to one of two things:
1) the database URL is incorrectly formed and doesn't match what is expected by the Driver. Yours looks fine.
2) the Driver was loaded but was not the one you expected - unlikely, but it's been done before. Yours looks fine.
A quick web search shows that one user solved the problem by moving to Tomcat 5. Does this help?
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Another thought occurred to me, try using "org.gjt.mm.mysql.Driver" as the Driver instead. I'm not sure why, but it might depend on the version of the Drivers you're using.
Dave
Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
I saw that thread as well, but I am already using Tomcat 5. I tried the other driver version, but that didn't help either. If I use that driver do I need to include the file for that driver like the taglib lines for the jstl files?
Rick Harding
Greenhorn

Joined: Mar 02, 2004
Posts: 18
Any other ideas?
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
seems to me that the JSP cannot find the jar file of the JDBC driver from the classpath, did you check whether you have put the jar file to:
$CATALINA_HOME/APP_NAME/WEB-INF/lib
?
or, does the jar file correct? In fact, you may try the newer jdbc driver, I forget the exact name, it seems be somewhat like... J/Connector version 3.x, right?
Nick.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
 
 
subject: problem with JSP connection & MySQL