473,788 Members | 2,725 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Queston on DB2 lock

Greetings,
We are connecting to a DB2 database residing on an AIX machine via
JDBC.

In order to lock some row of records, we use the "select . . . for
update . . . " Java statement:

In a multi user environment, we find that once a user locks the rows of
records, another user executing the "select ... for update . . . "
statement will wait, until the first user "commits" the transaction, so
that the rows will be unlocked.

Please let us know if there is a 'Non blocking" locking mechanism,
whereby, if the rows are locked, the statement fails with an
appropriate error message that could be traped, so that the application
could behave accordingly.

We understand that some database supports a "nowait" option, in the
"select" statement, i.e. "select for update, nowait . . . ". Is there
something equivalent in DB2?

Thanks in advance..

Nov 12 '05 #1
4 6036
<xe******@gmail .com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Greetings,
We are connecting to a DB2 database residing on an AIX machine via
JDBC.

In order to lock some row of records, we use the "select . . . for
update . . . " Java statement:

In a multi user environment, we find that once a user locks the rows of
records, another user executing the "select ... for update . . . "
statement will wait, until the first user "commits" the transaction, so
that the rows will be unlocked.

Please let us know if there is a 'Non blocking" locking mechanism,
whereby, if the rows are locked, the statement fails with an
appropriate error message that could be traped, so that the application
could behave accordingly.

We understand that some database supports a "nowait" option, in the
"select" statement, i.e. "select for update, nowait . . . ". Is there
something equivalent in DB2?

Thanks in advance..

The default setting for LOCKTIMEOUT in the db config is -1, which means that
DB2 will wait forever (unless a deadlock occurs). You can change that to the
number of seconds you want to wait before a -911 occurs. However, an
automatic rollback may occur with the transaction that gets the -911, so
test it to make sure it behaves as desired.
Nov 12 '05 #2
The following link could possibly help you out with what you are trying
to achieve

http://publib.boulder.ibm.com/infoce...n/r0011874.htm

Nov 12 '05 #3
The following link could possibly help you out with what you are trying
to achieve

http://publib.boulder.ibm.com/infoce...n/r0011874.htm

Nov 12 '05 #4
Hello,

a possible way to prevent your appl from either waiting for a lock or
failing with SQLCODE -911 (which includes an undesired rollback), you could
try to declare a static sensitive scrollable cursor to process your desired
rowset. Scrollable cursors use a kind of optimistic locking mechanism which
does not lock the original rows anymore after OPEN. If you update a row
within the open scrollable cursor then, but another process has already
updated this row in the meantime, your appl still gets an error sqlcode
(-224 afaik), but it will NOT be rolled back and thus can still decide what
do do now instead...

Regards - Walter.
<xe******@gmail .com> schrieb im Newsbeitrag
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Greetings,
We are connecting to a DB2 database residing on an AIX machine via
JDBC.

In order to lock some row of records, we use the "select . . . for
update . . . " Java statement:

In a multi user environment, we find that once a user locks the rows of
records, another user executing the "select ... for update . . . "
statement will wait, until the first user "commits" the transaction, so
that the rows will be unlocked.

Please let us know if there is a 'Non blocking" locking mechanism,
whereby, if the rows are locked, the statement fails with an
appropriate error message that could be traped, so that the application
could behave accordingly.

We understand that some database supports a "nowait" option, in the
"select" statement, i.e. "select for update, nowait . . . ". Is there
something equivalent in DB2?

Thanks in advance..

Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9534
by: xixi | last post by:
can someone explain to me what is internal p lock, internal s lock, internal v lock? when i have IS lock or IX lock , i always have these internal locks together for the application handle Application handle = 261 Application ID = AC100482.GD3A.00F85FE51898 Sequence number = 0006 Application name = db2jccmain Authorization ID ...
0
3389
by: Bruce Pullen | last post by:
DB2 v7.2 (FP7 - DB2 v7.1.0.68) on AIX 5.2.0.0. We're seeing unexpected single row (then commit) insert locking behaviour. We're seeing Applications that already hold row-level W locks in lock-wait, waiting to acquire row-level X locks. The lock-waits are behind applications that have row-level X locks on different rows (honestly). Both executing and lock-waiting applications have been granted IX table locks.
4
4374
by: Christoph Zeltner | last post by:
hi, i am writing a thesis on the concurrency control in db2 udb and oracle. I found in the documentary of db2, that a resource holding a (U)pdate-Lock can still be requested by a read-lock (e.g. S). If the U-Lock wants to convert to a write-lock, does the transaction have to wait for the transaction with the S-lock to finish ? Can it starve ? Is this the symmetric RUX-Protocoll ? Questions, so many questions ...
7
703
by: Sunny | last post by:
Hi, I can not understend completely the lock statement. Actally what is locked: 1. the part of the code between {...} or 2. the object in lock() In the docs is written: for 1: The lock keyword marks a statement block as a critical section by obtaining the mutual-exclusion lock for a given object, executing a
0
17818
by: Nashat Wanly | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaskdr/html/askgui06032003.asp Don't Lock Type Objects! Why Lock(typeof(ClassName)) or SyncLock GetType(ClassName) Is Bad Rico Mariani, performance architect for the Microsoft® .NET runtime and longtime Microsoft developer, mentioned to Dr. GUI in an e-mail conversation recently that a fairly common practice (and one that's, unfortunately, described in some of our...
3
6664
by: Raj | last post by:
I created a refresh deferred MQT, and during full refresh there were 4 or 5 lock waits, all waiting on a 'S' lock on Internal Catalog Cache ? Can some one explain how to prevent this from happening?
2
5867
by: shenanwei | last post by:
DB2 V8.2 on AIX, type II index is created. I see this from deadlock event monitor. 5) Deadlocked Connection ... Participant no.: 2 Lock wait start time: 09/18/2006 23:04:09.911774 ...... Deadlocked Statement: Type : Dynamic Operation: Execute
190
8191
by: blangela | last post by:
If you had asked me 5 years ago about the future of C++, I would have told you that its future was assured for many years to come. Recently, I have been starting to wonder. I have been teaching C++ at a local polytechnical school here in Vancouver, Canada for approximately 8 years. Six years ago, at the height (or should I say volume?) of the internet bubble, I had 80+ students per semester in my C++ course. Now I am fortunate to have...
94
30354
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock Statement (C# Reference) statement to serialize access. " But when is it better to use "volatile" instead of "lock" ?
0
9656
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9967
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.