GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  EJB
Go To First  |  Previous Question  |  Next Question 
 EJB  |  Question 38 of 175    Print  
What is the difference between optimistic locking and pessimistic locking

Answer posted by Mohan on 2005-05-21 17:20:02: Optimistic locking assumes that no one would read or change the data while changes are being by a bean 
Pessimistic locking would rather lock down the data so that no one can access it



  
Total Answers and Comments: 3 Last Update: September 03, 2007   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 21, 2005 17:20:02   #1  
Mohan        

RE: What is the difference between optimistic locking and pessimistic locking
Optimistic locking assumes that no one would read or change the data while changes are being by a bean 
Pessimistic locking would rather lock down the data so that no one can access it

 
Is this answer useful? Yes | No
May 27, 2005 23:31:43   #2  
John        

RE: What is the difference between optimistic locking and pessimistic locking
In optimistic locking the row will not be locked until the actual update is performed. In order to prevent the lost update issue a version number column will be used. In pessimistic locking the row will be locked at the time when the data is selected from the database. This will prevent other users who want to update the same record. This should not prevent the readers but this behaviour varies from database to database.
 
Is this answer useful? Yes | No
September 03, 2007 12:25:14   #3  
rossbertoloni Member Since: September 2007   Contribution: 1    

RE: What is the difference between optimistic locking ...

Optimistic Locking

Is based on the assumption that it is unlikely that separate users will access the same object simultaneously.  The EJB does not hold a lock for the duration of the transaction, just for the small period of time the EJB interacts with the DB. If db detects a collision, the transaction rolls back. Suitable for large systems requiring significant concurrent access.


Pessimistic locking:

The EJB holds a lock for the duration of the transaction, not allowing any other updates to the data. Suitable for small scale system where concurrent access is
rare.


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape