• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data corruption in multi user web application

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello. My company currently has a J2EE web app serving about 300 internal employees. Now that the app is being heavily used, we are noticing data corruption by the users. For example...

Step #:
1) User A is served a jsp which contains a form filled with data ready to be updated.
2) User B is served a jsp which contains a form filled with data ready to be updated. This is the same data as User A.
3) User A changes the data, and clicks "Update". The commit is done in Oracle.
4) User B, never seeing User A's change because the jsp was not refreshed, submits their changes (which are different from User A's). This overwrites User A's data with User B's and the first set of changes are lost.


Is there any Oracle/JDBC/Java best practices to resolve this? There must be something since web apps are so popular now....

TIA


 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, this is an old, and quite fundamental, problem with database backed applications (which predates web apps by some considerable time). Your application needs to implement a locking strategy of some sort. Have a google, or search these forums, for "optimistic locking".
 
Jason Mrick
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:Yeah, this is an old, and quite fundamental, problem with database backed applications (which predates web apps by some considerable time). Your application needs to implement a locking strategy of some sort. Have a google, or search these forums, for "optimistic locking".



Awsome! I will take a look! Thanks again.
 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, depending on the frequency of this problem, you can check to see whether the data had been updated before you try to update it and respond with an error if this is the case. For example, you can add a lastUpdateDate (date/time) on the table you are updating. Read this along with the other data (but do not let the user update the field). When you update the data in the database, compare the lastUpdateDate with the one in your database and discontinue the update if they are unequal.
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Reilly wrote:Or, depending on the frequency of this problem, you can check to see whether the data had been updated before you try to update it and respond with an error if this is the case. For example, you can add a lastUpdateDate (date/time) on the table you are updating. Read this along with the other data (but do not let the user update the field). When you update the data in the database, compare the lastUpdateDate with the one in your database and discontinue the update if they are unequal.



No "or" about it - that's optimistic locking.
 
Jason Mrick
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tom Reilly wrote:Or, depending on the frequency of this problem, you can check to see whether the data had been updated before you try to update it and respond with an error if this is the case. For example, you can add a lastUpdateDate (date/time) on the table you are updating. Read this along with the other data (but do not let the user update the field). When you update the data in the database, compare the lastUpdateDate with the one in your database and discontinue the update if they are unequal.



Yeah, this was the approach we came up with so far but wanted to see what other options we had out there.....
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

No "or" about it - that's optimistic locking.

Excellent! Now I know what to call it without running out of breath :-)
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic