This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Locking a table for read  RSS feed

 
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.
 
Bartender
Posts: 2633
17
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!