• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP mySQL exception

 
Chris Cingrani
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to connect to a mySQL database that is hosted remotely. I am sure I am putting in the correct information to correct, however, every time I try and run the .jsp code, it will display the column headers and then go to the exception, with no error being displayed. Here is the code I am using. Any thoughts would be appreciated!
Thanks -
Chris
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No error message at all?? Anything else you can give us? without an error, I don't see anything wrong with your code.
 
Chris Cingrani
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gregg -
All it displays is this:
Begin Exception Dump
End Exception
Not much to go on, which is why I am baffled. I don't understand why the e.getMessage() doesn't return something.
Chris
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chris Cingrani:
Gregg -
All it displays is this:
Begin Exception Dump
End Exception
Not much to go on, which is why I am baffled. I don't understand why the
e.getMessage() doesn't return something.

hi dear,
Have you tried writing e.printStackTrace(out), bcoz i dont think your program know where to show the error. "out" is defined as an object of PrintWriter, & that would print the error on the screen.
if you are using tomcat, you can check the logs at <tomcat-home>/logs to find the error. You can check file with today's date as its filename.
hth
MB
[ August 04, 2003: Message edited by: Malhar Barai ]
 
Sam Walker
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Hi I think the problem may be that url cannot include user id and password. There�s another getConnection method specifically for passing user and password. replace:

conn = DriverManager.getConnection("jdbc:mysql://localhost/dbName?user=me&password=pass");

with getConnection("jdbc:mysql://localhost/dbName", "me","pass");

The getConnection() statement is a regular JDBC statement and the syntax applied to it must be based on JDBC specification.
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Sam Walker:
Hi,
Hi I think the problem may be that url cannot include user id and password. There’s another getConnection method specifically for passing user and password. replace:
with getConnection("jdbc:mysql://localhost/dbName", "me","pass");

The getConnection() statement is a regular JDBC statement and the syntax applied to it must be based on JDBC specification.

hi Sam
That can't be a problem because you can indeed include the username & password in the URL.
chk the following link
User & password
hth
MB
 
Chris Cingrani
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everyone for their replies thusfar. In regards to Malhar's comments, I wanted to mention that the Exception handler will output a message at times. For instance, if it cannot find the jdbc.Driver class the message displays as follows:
Begin Exception Dump
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
End Exception
So, the messages will display, it's just that no errors are coming back in this instance. Also, I can't access the log files for Tomcat because it is hosted remotely.
Any other ideas?
Thanks -
Chris
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
Exception object "e" just gets the error message by e.getMessage(), but not the stack trace.
To get the error trace on your page, you indeed have to specify e.printStackTrace(out); , give it a try, if that doesnt work, you can get the complete trace in a text file, try the following code :

View the text file, & you can know the error, w/out seeing the log file of Tomcat.
hth
MB
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But you should just be able to log the stack trace directly to the screen using e.printStackTrace( new java.io.PrintWriter( out ) );
 
Sam Walker
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Chris,
How sure are you that all the jar files you need are in your classpath or where they can be found? Could this be a situation that the class loader finds two different versions of the same class? That happened to me once and I was getting strange problems.
 
Chris Cingrani
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the modifications Malhar and David recommended, but still no difference. There isn't anything being displayed between Begin Exception Dump and End Exception.
This is starting to drive me nuts....
Chris
 
Asher Tarnopolski
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
did you try to do this:
%>Begin Exception Dump<P><%
<%=e.getMessage())%>
<%= e %><P>End Exception<%
?
and if thisdoesn't help, did you try to totally remove user/password part from your url? try to run it without them.
[ August 05, 2003: Message edited by: Asher Tarnopolski ]
 
Malhar Barai
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi again

if the database is hosted remotely, why are you using "localhost" in the connection string. Shouldn't it be the IP of the remote host.

hth
MB
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic