• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Strange JDBC transaction problem

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Two JDBC transcations are runned concurrently. They update the same table, but different records. Since they update different records, they should not affect each other. But the result shows that the 2nd transaction cannot continue until the 1st transaction finished.
Isolation level is set to Read Commited. I'm using weblogic 6.1 + db2 7.1
Transaction 1
1)transcation begin
2)update record1
3)(let the thread wait for 60 seconds on purpose....)
4)update rec2
5)transcation end
Transaction 2
1)transcation begin
2)update rec3
3)update rec4
4)transcation end
Can anyone explain why would this happened? How to fix this problem?
Thank you
Tom
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are 2 types of LOCK in dbms: table-locked and row-locked. maybe you should consult the db2 documentation.
I don't think these 2 transcation can run concurrently. for example:
the table "table1" like this:
--------------------------
field1 field2
'aa' 12
'bb' 20
'cc' 30
--------------------------
update1 is "update table1 set field2=22 where field1='aa'"
update3 is "update table1 set field1='dd' where field2>=20"
the result of the these 2 transaction is not sure if they run concurrently.
 
Tom Chen
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Frankie,
I finally found that it is because Primary Key is not specifed for the table. I think Primary Key is a must for the row level locking.
Thank you very much,
Tom
[ January 15, 2003: Message edited by: Tom Chen ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic