• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difficulties inserting data in database using ControllerServlet

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 624
9
BSD Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?

 
Bartender
Posts: 2856
10
Firefox Browser Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic