Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

database locking  RSS feed

 
k doshi
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a requirement that if one person is accessing some record in the database, then the other person should not be able to access it.
can this be done in EJB at transaction level, or do i have to do it on Database level.
thanks for the replies
Kiran
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If by access you mean both read and write then you can achieve your goal by setting your EJB's transaction isolation level to Serializable. This will give the transaction exclusive read and update privileges.
Setting the transaction isolation level is handled in a vendor-specific manner. Check the documentation for your application server for more information or post the question to the appropriate forum here on JavaRanch. I am sure you will find someone to help you.
 
kettle
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most of the cases are handeled good with READ_COMMITED. It will allow Dirty and Phantom Read and most of the APP server WebSphere/Weblogic take care of tx management.

As SERIARLIZED will impose too much of constrain resulting into slow response.
It depends how much control you want.
Kettle
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!