• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Update resturns zero rows updated without throwing errors.

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
ajay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
might be there is something wrong in your query and your query is failing....put your code here

Shailesh
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
Posts: 1143
1
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic