This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Locking a table for read Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Locking a table for read" Watch "Locking a table for read" New topic

Locking a table for read

Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384

I need to lock a table for reading through jdbc. Note that I am only performing a read (select) and I have no control over the database configuration. Is what I want to achieve still possible?

I use a standalone java app together with ibm db2 for as400.

Thanks in advance,

Jan Cumps

Joined: Dec 20, 2006
Posts: 2541

You should not need to lock a table for reading. Reading a record works without locking.
What is the reason that you have this requirement?

Some databases allow you to lock when you do a It doesn't guarantee that you have a row, segment, or table lock. You will have to properly release the lock (by closing the transaction). Read your database's documentation on the 'for update' clause, and if it does what you want.

OCUP UML fundamental and ITIL foundation
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Thanks a lot for the reply!
All the best,
wood burning stoves
subject: Locking a table for read
jQuery in Action, 3rd edition