This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes updateing Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Reply Bookmark "updateing" Watch "updateing" New topic
Author

updateing

Mandy Bowman
Ranch Hand

Joined: Jan 24, 2007
Posts: 32
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?
Muhammad Shafique
Ranch Hand

Joined: Sep 30, 2006
Posts: 57
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

Joined: Jan 24, 2007
Posts: 32
I guess that's even better. Are we required to do this much work though?
Lorenz Baylon
Ranch Hand

Joined: Jan 04, 2006
Posts: 99
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


I just cant look, its killing me.
Gabriel Vargas
Ranch Hand

Joined: May 16, 2007
Posts: 145
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?


Gabriel Vargas
SCJP, SCJD, now studying for SCWCD and working to be a better person
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: updateing
 
Similar Threads
SCJD obstacles
Record Caching, Reading Records
Updating clients when record has been modified?
Buffering and Locking
My Locking Approach