Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Locking a table for read

 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

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,

Julien.
 
Jan Cumps
Bartender
Posts: 2584
11
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Julien Martin
Ranch Hand
Posts: 384
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the reply!
All the best,
Julien.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic