File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes locking and unlocking mechanism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "locking and unlocking mechanism" Watch "locking and unlocking mechanism" New topic
Author

locking and unlocking mechanism

Joseph Tsui
Greenhorn

Joined: Jan 05, 2002
Posts: 6
Hi All,

I am trying to implement a client program that can obtain record from MSSQL. I am using hibernate to do that.

So client A and client B will get record from DB server
both client A and B are on different machines

How can i prevent the situation that

ClientA get
ClientB get
ClientA update
ClientB update

In the database, i have a retrieve flag for each record. once the client get the record, it will update the record with the retrieve flag = true

Anyone can provide me advice on that? thanks a million
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Have a google (or a search in these forums) for "optimistic locking" - this is techique usually used to solve the lost update problem. Also, have a read of the Hibernate documentation about versioning, which is Hibernate's optimistic locking implementation.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
wood burning stoves
 
subject: locking and unlocking mechanism