MySQL Forums
Forum List  »  Newbie

JDBC executeUpdate always returning 1 even if no rows were updated?!
Posted by: Darryl Cheung
Date: August 25, 2004 03:48PM

I just started using MySQL and connected it to a Java front-end using MyConnector/J & JDBC. In my front-end, I save all the data in the table by calling executeUpdate with (UPDATE <table> SET <COL1>=<VAL>, <COL2>=<VAL> etc. WHERE <PRI-KEY> = <VAL>)

My question is: does executeUpdate() return the number of rows that matched or the number of rows that were actually changed?

When I run the query from the MySQL console, I can see that 1 rows matched and if the values of the columns are exactly the same as what I am using in my query, the number of rows changed is 0.

However, when I look at the return value of executeUpdate() in my Java program, it is always 1 even if the values are not updating anything.

The whole purpose of this exercise is to show how many rows actually have new data should the user change the data in the front-end GUI and did a save. To say that every row has changed even if no data has been updated isn't correct.

Any comments are appreciated. Thanks!

Darryl

Options: ReplyQuote


Subject
Written By
Posted
JDBC executeUpdate always returning 1 even if no rows were updated?!
August 25, 2004 03:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.