开发者

connecting to database using servlets

开发者 https://www.devze.com 2023-04-12 01:16 出处:网络
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?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号