• 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

Do Threads Block on Database Resources?

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

Suppose a thread opened a connection to a database and acquired an exclusive lock on a table to delete some rows.

What happens when a second thread tries to select a row from that locked table(or to update a row of the table) before the first one releases the lock by a commit or rollback?

Does it wait for the lock of the table to be released(namely,blocks?), does it throw an exception, or something else?

Thanks in advance...
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't look very much like a SCJP type question so I'll move it somewhere like here in JDBC.
[ June 30, 2004: Message edited by: Barry Gaunt ]
 
Ranch Hand
Posts: 155
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by savas karabuz:
Hi all,

Suppose a thread opened a connection to a database and acquired an exclusive lock on a table to delete some rows.

What happens when a second thread tries to select a row from that locked table(or to update a row of the table) before the first one releases the lock by a commit or rollback?

Does it wait for the lock of the table to be released(namely,blocks?), does it throw an exception, or something else?

Thanks in advance...



The other threads wait (if serializable transaction for select or if insert or update) for determined amount of time unless the "nowait" is specified in the sql statement.
Last, the transaction settings on the datasource and/or database will determine what type of operations will be possible when a row or table is locked.
[ June 30, 2004: Message edited by: Brahim Bakayoko ]
 
Anderson gave himself the promotion. So I gave myself this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic