aspose file tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question regarding lock in SCJD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question regarding lock in SCJD" Watch "Question regarding lock in SCJD" New topic
Author

Question regarding lock in SCJD

Luiz Reginaldo Curado
Ranch Hand

Joined: Jan 19, 2006
Posts: 108
Suppose I have the folowing:

- Client A selects a record, the update screen is showed
- Client B selects a record, the update screen is showed
- Client A update the record (lock, update, unlock)
- Client B update the record (lock, update, unlock)

So, client B will overwrite what A had done. Is it ok to the assignment???

Please, post your suggestions. I'm very confused about that in the assignment...
Daniel Bryant
Ranch Hand

Joined: Jul 15, 2006
Posts: 54
Hi Luiz,

I would have to say no to that being ok...

But how about this?

- Client A selects a record, the update screen is showed
- Client B selects a record, the update screen is showed
- Client A update the record (lock, READ RECORD, CHECK EXPECTED VALUES, update, unlock)
- Client B update the record (lock, READ RECORD, CHECK EXPECTED VALUES, update, unlock)

where the READ RECORD, CHECK EXPECTED VALUES part of the process reads the record again (which has now been locked) and compares this read with the existing data (i.e. the data you expect). If the two don't match you know that someone has updated the record before you, and you can abort the process and inform the user accordingly.

Best wishes,

Daniel


SCJP 1.4,<br />SCJD (URLyBird 1.2.1, JDK 5.0)
 
wood burning stoves
 
subject: Question regarding lock in SCJD
 
It's not a secret anymore!