This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes Update resturns zero rows updated without throwing errors. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "Update resturns zero rows updated without throwing errors." Watch "Update resturns zero rows updated without throwing errors." New topic
Author

Update resturns zero rows updated without throwing errors.

ajay
Greenhorn

Joined: Dec 15, 2004
Posts: 6
In one of our application code, we are performing executeUpdate on a prepared statement object. This is done in a loop on a large number of records, say 20000.
On some occasions, the update fails to update the table with relevant information and returns without throwing any errors.

We need to know the reason why it is not updating the table even though the query is right?

Also, under what conditions does the update return zero rows ?

Steps taken :

1. Create and populate the preapred statement with values.

2. Lock the particular row for update.

3. executeUpdate on this prepared statement object.

4. release the lock.
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1112

austraind,
You asked:

under what conditions does the update return zero rows ?

When no rows satisfy the "WHERE" clause of your UPDATE statement, for example:

If there is no employee named "Paris Hilton" in your EMP table, the above statement will update 0 (zero) rows and will not throw any errors.

Good Luck,
Avi.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 56219
    
  13

"austraind",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
ajay
Greenhorn

Joined: Dec 15, 2004
Posts: 6
Thanks avi,But all the conditions are satisfied. The where clause is right and i have the matching parameters in the DB. Still it fails consistently.

This is a serious issue for us, since it is affecting the performance of our code badly.

Anyone out there who has faced such an issue before ?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1076

might be there is something wrong in your query and your query is failing....put your code here

Shailesh


Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"ajay",

Please read Bear's post more closely:
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Please fix your display name soon, accounts with invalid display names get deleted, often without warning.

Dave
Avi Abrami
Ranch Hand

Joined: Oct 11, 2000
Posts: 1112

Ajay (or Austraind?),
You said:

The where clause is right and ... Still it fails consistently.

Well then something is wrong, so post your code (like Shailesh suggested) so that we can debug it for you.

By the way, I am currently looking for new employment -- since my current position is only temporary. Perhaps if I solve your problem for you, your employer would consider employing me (instead of you)? Just kidding

Good Luck,
Avi.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Update resturns zero rows updated without throwing errors.
 
Similar Threads
Statement, Prepared Statement, and CallableStatement
Prepared Statement.. when it fails what to do ?
executeUpdate method is returning zero.
Html Input to oracle through servlet and JSP output
Statement functions