File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC 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
JavaRanch » Java Forums » Databases » JDBC
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: 2491

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
youtube channel
Julien Martin
Ranch Hand

Joined: Apr 24, 2004
Posts: 384
Thanks a lot for the reply!
All the best,
I agree. Here's the link:
subject: Locking a table for read
Similar Threads
How to ensure a read-only table will never be locked?
change the column type
hex to String Help!!!!!!!!!!!!!!!!!!!!
make db table read only
return as xml document