• 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 consurrency/integrity issue

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys,
I was wondering if somebody can throw me a few thoughts on the issues of data integrity on the database side of the SCJD project.
Heres the scenario, 2 clients running in network mode, they both get a snapshot of flights and match the same flight, not uncommon.
Client 1 books 2 seats and the avaliable seats in the database is reduced by 2.
Then client 2 books 5 seats on the same flight, but has an old avaliable seats count, and that count (within the DataInfo record) is overwritten in the database with the original seats avaliable value minus client 2's requested seat booking. The result is client 1's booking has been overwritten.
How are you all combatting this:
- I can think of one way and that is to check the available seats ON THE SERVER before you perform the booking but that will be inconsistent with the current user data, and confusing to the user, unless you inform them specifically ?
Any thoughts ?
Mick
 
Michael Bulpin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Additional info,
My SCJD requirements specifically state :
"It is not necessary to provide for live updates on multiple clients when new bookings are made at other clients".
But it doesn't state that data integrity (a byproduct of this non-requirement) issues should not be resolved !
Its a curly one !
Mick
 
Ranch Hand
Posts: 2937
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


- I can think of one way and that is to check the available seats ON THE SERVER before you perform the booking but that will be inconsistent with the current user data, and confusing to the user, unless you inform them specifically ?


You have the right idea, and yes, it might be incosistent if the seat count in the JTable is less than the actual count in the database, but it's OK as long as you check the actual count each time the booking is requested. This is exactly what Sun wants for this assignment (I assume it is a regular assignment, not Beta).
Eugene.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An additional data point: you don't have to perform the check on the server -- in fact, I would argue that you must not perform the check on the server. Let the client handle the check. The lock() function is your friend.
- Peter
 
Michael Bulpin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Peter and Eugene,
Thank you for your quality comments and I have taken them both on board. I now read the target record from the server (not performing checks on server - that would violate its generic nature) and proceed to do all checks on the client, then perform the booking (via my friend lock().
I am happy with this solution. Thanks for your help guys !
Mick
 
reply
    Bookmark Topic Watch Topic
  • New Topic