• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

updateing

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A question about updateing records. In B&S we are meant to book contractors. Now this involves geting the record number of the record you wish to update and then calling update(recNo, data) to update that record so that it gets booked. Now I can see two ways in which to get the data that we want to update. The first is to get the data from the selected row in the JTable and the second is to make a call to the server to re-get the data from the database. I prefer the second option as this would mean that we are getting the most up to date information from the server (there could have been chages to that record since your search). Does anyone disagree?
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What if data is updated immediately after you get it from server?
The better way could be:
-Get user changes.
-Lock record
-Compare server data with pre-updated data on your GUI.
-If there is no change, update on server.
-If server data is different than your copy of pre-updated data, update GUI with server data and prompt user to enter his/her data again.
-Unlock

This seems a good approach to me.

Regards,
Shafique
 
Mandy Bowman
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess that's even better. Are we required to do this much work though?
 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mandy,

For me I'd prefer to use the latter, since the data being displayed in the JTable may not be current (or the user needs to refresh the JTable data before he the program calls the update method, but not such a good thing). How about reading the data from db, lock it, check for changes, inform user about the change if there's any, update, release lock, then update JTable display?

Regards,

Lhorenz
 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I read this topic, and i also have the same issue


What if data is updated immediately after you get it from server?
The better way could be:
-Get user changes.
-Lock record
-Compare server data with pre-updated data on your GUI.
-If there is no change, update on server.
-If server data is different than your copy of pre-updated data, update GUI with server data and prompt user to enter his/her data again.
-Unlock

This seems a good approach to me.



But in my approach there are two states, booked and not booked, so if I try to book a record than has a change (a change means than had been booked) I get an exception because a record booked cannot be booked again, only can be pass to not booked state. (Yes, it applies only to update to book a record). What do you think about that approach?
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic