File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Should I lock the database when createRecord?

 
Bigwood Liu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18671
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Bigwood Liu
Ranch Hand
Posts: 240
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, thank you Jim
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic