I could use some help on the following. I am reading up on servlets and JDBC via JavaServlet Programming by Jason Hunter. I have looked at this so long I just can't see my error, but there must be something wrong! I am trying to makeup a simple servlet example using a html form to pick up a parameter from the user and pass it on to the servlet. The servlet should perform an update on the database. When I look at the database nothing is being added. The database is an Access DB and it is hooked up correctly. I can use another app to look at the database and perform a select * from Table1 and see that nothing is added. I am using Tomcat 4.0.1. I have tried doPost and doGet neither worked. I have tried text and int for the parameter. The database is one table called of all things Table1 with the first column SSNum as Number and the next three columns as Parameter1, Parameter2, Parameter3 all as text. Got any ideas? Thanks.
(Marilyn added code tags and disabled smilies) [ September 29, 2003: Message edited by: Marilyn de Queiroz ]
Thanks for replying Sainudheen Mydeen. I was able to get this going by using a preparedstatement, just as you suggested. I know that not all databases are able to use preparedstatement, in particular MySql. I was hoping that somebody could suggest a way to make this work without using a preparedstatement. However I am about to become bald from pulling out my hair trying to understand this database stuff. Can somebody explain why the following is happening. I am using Access as the database. This code from a book almost runs but leaves out the last row of data.
The data for insert values 123, name1 and 987, name2 are added to the database but 555, name3 is not! Now I would not mind this happening with my checking account on the debit side, but it would definitely not be good for the credit side. Now if I try much the same code with a servlet, it does not work at all.
Why oh why will this almost work as in the first code example and utterly fail on the second? The only real difference that I see is the servlet
Joined: Aug 18, 2003
Hi Bob Young I tried to run your program connecting to my Oracle datbase. Both work fine. All three rows inserted. If you are calling your servlet by typing the URL in browser's address bar, change the method name to doGet. ----------------- Sainudheen