jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes locking and unlocking mechanism Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "locking and unlocking mechanism" Watch "locking and unlocking mechanism" New topic

locking and unlocking mechanism

Joseph Tsui

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

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
I agree. Here's the link: http://aspose.com/file-tools
subject: locking and unlocking mechanism
It's not a secret anymore!