This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes How can i explicitly lock a row of a Table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "How can i explicitly lock a row of a Table" Watch "How can i explicitly lock a row of a Table" New topic
Author

How can i explicitly lock a row of a Table

Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Hi

How can we implement optimistic locking , i am using Oracle as Database for my Application .

Assume that i am working on a single row of a Table .

Now please tell me how can i explicitly lock this row , so that other simultanoues users insert or update operations are not affected to this particular row .

I am not using any ORM related technology

Please help .



Save India From Corruption - Anna Hazare.
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Row locking is not optimisitc locking, its pessimistic locking. You do this by using the select...for update syntax in Oracle.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

You do this by using the select...for update syntax in Oracle.



can you please elobrate this answer .
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Select for update selects a set of data locking it from updates by other transactions (i.e. pessimistic locking). Other than that there is not much extra I can really say. Have a look at the Oracle documentation for select, it has a more complete answer than I am likely to give here.
Ravi Kiran Va
Ranch Hand

Joined: Apr 18, 2009
Posts: 2234

Thank you .
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i explicitly lock a row of a Table
 
Similar Threads
static synchronized vs non-static synchronized
using JOtionPane
duplicate row for editing
How to put Row level lock in java while inserting a row in MSSQL table
Optimistic Or Pessimistic locking .