connecting to database using servlets
I am trying to connect to database using java servlets. Somehow I am not able to get to display results on the web page. Here is my source code. Can anyone let me know if I am missing something?
If you want to downvote the question, supply a reason开发者_高级运维 for doing so.
Try to remove the try catch of the SQLException
} catch(SQLException ex) {
and just throw the exception in the signature of the method to see if your code doesn't really throw an exception.
You're just writing to standard output in case of exception and you didn't tell us which server you're using. Your exception can be silently lost.
You should really use a logging framework instead, but for a quick check you can just add:
throws SQLException
to the method signature.
One more comment. I think you're learning about servlets so I will excuse your code, but in real life you don't want to use any SQL related method directly in a servlet.
精彩评论