Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error 500 when trying to run servlet connecting to mysql

 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone,

I have wrote this piece of code to test whether I can connect to my MySQL database with a servlet.


When I run the servlet I am presented with the error 500 message, the error message reads:


Does anyone have any idea where I am going wrong?

Thanks,
-Ben
 
Campbell Ritchie
Sheriff
Posts: 48910
58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will have to go through the usual procedure for finding a NullPointerException (NPE). Start by identifying the line where it occurs (35) and check that every object used in that line is not null.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34372
345
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, check your error logs.


These two pieces of code log an error and then continue. If either of these fails, the code later in the method doesn't make sense though. It's better to just log the error, throw a RuntimeException and stop trying.
 
B Crosthwaite
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys thanks fot the replys,

I just want to make sure of something.....

If I had set up the JDBC driver Incorrectly would I be able to complie the code in the above post?

I realise that this is a strange question considering the first post I made but I would just like to make sure I have installed the driver correctly.

Thanks,
Ben
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic