Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with JSP connection & MySQL

 
Rick Harding
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any other ideas?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic