Is it possible that manipulation in DB2 control center blocked query in java code?

StackOverflow https://stackoverflow.com/questions/23467531

  •  15-07-2023
  •  | 
  •  

سؤال

I'm doing a sql query in some java code, but the execution blocked at a call to ResultSet.next(). At the same time, I found I'm visiting the queried table using IBM DB2 Control Center. When I closed Control Center, the call to ResultSet.next() is resumed. So I suspect my manipulation on Control Center locked the queried table. Is this possible? How can I confirm this(i.e. how can I know if a certain table is locked in DB2)?

هل كانت مفيدة؟

المحلول

Yes, it can be blocked depending, on the queries. It does not matter that it is the control center, it can be any other kind of connection. The fact is that in a connection, you put a lock on a table or a row, and the other connection tries to access that table or row, however the second one stays in 'Lock Wait' because it should wait for the lock release from the first connection.

Let's suppose you create a table from the Control Center, but you does not execute a commit. When you issue a select from the Java application, the table is with a lock wait on it. You should issue a rollback or commit in the control center in order to release the lock.

In order to see the locks, there are many tools, however, db2top, option u is a good one for me when analyzing real time situations.

Finally, why you use control center? it is outdated. Try IBM Data Studio.

نصائح أخرى

While AngocA is right in general, it must be said that what you experienced may hint to some configuration problems, as two read-only transactions shouldn't lock out each other under normal circumstances.

DB2 normaly uses row locking. However, if the number of locked rows gets too big for the so called lock list, the db2 server may perform a so called "lock escalation" and replace millions of row locks for some table with a single exclusive lock on the table.

The behaviour also depends on the so called isolation mode used, but this is a topic not easily explained in a SO post; you need to read some documentation to understand it.

The size of the lock list can be configured with db paramater LOCKLIST. The diagnostic log (look for file db2diag.log) tells you whether lock escalations have taken place.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top