File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raghavan Chockalingam
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Duffy
Ranch Hand
Posts: 163
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, something like this is what I was looking for...this is more similar to mysql_affected_rows() in PHP...
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic