aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: Should I lock the database when createRecord? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "NX: Should I lock the database when createRecord?" Watch "NX: Should I lock the database when createRecord?" New topic
Author

NX: Should I lock the database when createRecord?

Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi,
the instruction doesn't tell us to lock the database file when creating a record, but it is a kind of operation to modify the databse, it should be locked, am I right, need your help.
Regards, Damu
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
But what should be locked? The update() and delete() methods modify a record, and require that you lock that record before calling those methods. But for create(), the record doesn't even exist yet, so what do you lock?
You may well need to do something to prevent problems in case another thread tries to read/update/delete the record while it's still being created, or tries to create another new record. (Make sure both records don't get the same record number, for example.) Probably you will find that some sort of synchonization is helpful. But beware that it won't (can't) work the same as locking of records, because the record you;d need to lock doesn't exist yet. So you'll have to think about how to handle this problem in your code...


"I'm not back." - Bill Harding, Twister
Bigwood Liu
Ranch Hand

Joined: Feb 26, 2003
Posts: 240
Hi, thank you Jim
 
Don't get me started about those stupid light bulbs.
 
subject: NX: Should I lock the database when createRecord?
 
Similar Threads
Database lock (-1)???
Locking the whole database
lock the the entire database
Lock the database
Logic lock must act like a real one: cause the current thread to give up the CPU