This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Difficulties inserting data in database using ControllerServlet  RSS feed

 
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
 
Master Rancher
Posts: 4087
47
  • 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?
 
Ranch Hand
Posts: 624
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?

 
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!