| Author |
inserting into a database problems
|
Bron Czimes
Ranch Hand
Joined: May 09, 2004
Posts: 44
|
|
well, I have been looking at this for hours (which could be one of my problems) and I can't seem to work out what is wrong. i have a servlet that is supposed to be entering some data for me (this is a web-based application by the way). the program works fine, shows no errors, but when I go to check the database, nothing has happened! no data is entered into the table that I specified, and because I'm not getting any error messages whatsoever, I have no idea what the problem is. The code is.... Can somebody please tell me what is wrong? [Bear edit: removed potentially offensive slur] [ October 07, 2004: Message edited by: Bear Bibeault ]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
What is the executeUpdate returning? You don't even check.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bron Czimes
Ranch Hand
Joined: May 09, 2004
Posts: 44
|
|
Thats because I dont need to use the result anywhere. I just need some information generated by my program to be inserted into the database at this point. I was under the impression that executeUpdate() cannot or should not return a result (throws a SQL exception instead).
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56185
|
|
|
It returns the number of records that were updated/inserted/deleted.
|
 |
Bron Czimes
Ranch Hand
Joined: May 09, 2004
Posts: 44
|
|
ok, I tried to do a getResultSet() to see if any thing is returned and it turns up blank :S so I'm assuming this means that nothing is being updated?? is that the correct assumption to make? so what do I do now?
|
 |
Adeel Ansari
Ranch Hand
Joined: Aug 15, 2004
Posts: 2874
|
|
i dont know if you can get the result set by getResultSet(), though you are executing executeUpdate(). - why are you doing executeUpdate() with select statement? - while updating the records, what are you expecting in a resultset mate?
|
 |
Sonny Gill
Ranch Hand
Joined: Feb 02, 2002
Posts: 1211
|
|
Try to change your code as follows Give an initial value to temp, just to get the program working. Later you can check for invalid values or other conditions etc. Use executeQuery() instead of executeUpdate, because you want a ResultSet containing the records returned by the ResultSet. Hopefully this takes you a step closer to what you are trying to do. Sonny
|
 |
Bron Czimes
Ranch Hand
Joined: May 09, 2004
Posts: 44
|
|
Thanks Sonny, that helped. Thanks all.
|
 |
 |
|
|
subject: inserting into a database problems
|
|
|