aspose file tools*
The moose likes JDBC and the fly likes How to find insert/update/delete queries are successful in PreparedStatements[solved] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How to find insert/update/delete queries are successful in PreparedStatements[solved]" Watch "How to find insert/update/delete queries are successful in PreparedStatements[solved]" New topic
Author

How to find insert/update/delete queries are successful in PreparedStatements[solved]

Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
I am new to prepared statements and I am trying to insert a new record. But the return value is false,,,but when I had a look at the value in the table, a new record is inserted...why does it return false..how do you normally confirm that an insert/delete operation is successful?
[ January 03, 2006: Message edited by: Raghavan Chockalingam ]

Raghavan
SCJP 6
Michael Duffy
Ranch Hand

Joined: Oct 15, 2005
Posts: 163
Originally posted by Raghavan Chockalingam:
I am new to prepared statements and I am trying to insert a new record. But the return value is false,,,but when I had a look at the value in the table, a new record is inserted...why does it return false..how do you normally confirm that an insert/delete operation is successful?


My guess is that you're probably using the execute() method, which returns true if the SQL statement returns a ResultSet and false otherwise.

If you use the executeUpdate() method instead, it assumes that there's no ResultSet and returns the number of affected rows instead. That sounds more like what you want.

Am I on the mark?


%
Raghavan Chockalingam
Ranch Hand

Joined: Dec 20, 2005
Posts: 77
Thanks, something like this is what I was looking for...this is more similar to mysql_affected_rows() in PHP...
 
jQuery in Action, 2nd edition
 
subject: How to find insert/update/delete queries are successful in PreparedStatements[solved]