• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difficulties inserting data in database using ControllerServlet  RSS feed

 
Benji Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellow greenhorns!

New greenhorn here ;)

I'm trying to insert data into mysql database based on form input but no data get inserted and no matter how hard I try I can't seem to get it work... The file and the program compile fine. I'm able to fill out the form and send the page successfully where its supposed to go but nothing gets inserted and printed on the page (not even an error message!) Any help is very welcome!


ControllerServlet.java



form.jsp
 
Dave Tolls
Rancher
Posts: 2914
36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add debug statements, logging the data that comes in and where in your code you end up going.
Without that then you are simply guessing that it is following the flow of code you posted.
 
Benji Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Tolls wrote:Add debug statements, logging the data that comes in and where in your code you end up going.
Without that then you are simply guessing that it is following the flow of code you posted.


Thanks for your answer Dave! There are debug statements in my code... I use System.out.println() in the Servlet... What are you suggestions? Do you see anything wrong with the overall code?
 
Tapas Chand
Ranch Hand
Posts: 614
9
BSD Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I cannot see a single print statememt in your servlet.
Are you posting the same code?
 
Benji Xu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tapas Chand wrote:I cannot see a single print statememt in your servlet.
Are you posting the same code?


Yes. This is the code... I thought the code snippet below was a print statement?

 
Amit Ghorpade
Bartender
Posts: 2856
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes that statement is for printing. But it is for printing to the output (HTML page in this case). It is not a log or debug statement.
Have you looked at the server logs? What do you see there?
Also I don't think you are able to connect to the DB, your connection URL should not contain the user and password.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!