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

optimistic and pessimistic concurrency control?

 
Aaron Raja
Ranch Hand
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Difference between optimistic and pessimistic concurrency control? can you tell me at what kind of senerio we use this ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Optimistic concurrency control (or optimistic locking) is a technique used with relational databases whereby you use versioning to avoid lost updates. It works by adding some sort of version field to an entity. When your application selects a record from that table it notes the version, when you try to update the record you check the version to see if it is the same. If it isn't, you know that some other process has updated the record and the copy your application has is out of dat, so no update should take place. It is used so as to not require exclusive row locking everytime your application selects a record it them may update, and its called "optimistic" because it works on the assumption that most of the time there will be no conflicts.

Pessimistic concurrency control (or pessimistic locking) is where a row is exclusively locked for the entire duration it is in applciation memory. It is to be avoided, unless you have a good reason to need it, because becomes a bottleneck where more and more users are stuck waiting for locks to be released.
 
Aaron Raja
Ranch Hand
Posts: 206
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic