• 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

Lock while Updating?

 
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In SQL server if the program is updating a row and at the same time if a program is trying to read that particular row which is being updated then what happens assuming that the transaction level is set to read_committed.
Will there be a lock and the thread try to read that row will wait till the lock is released or will it read the previous data of the row and display it to the user? What happens if the transaction is set to read_uncommitted?

Similarly what happens if 2 threads are trying to update the same row at the same time?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, it will depend on your database implementation but..

I believe 'read commited' usually means 'Show me only rows who's changes have been committed to the database'

So, if you try a read a row whilst a write is taking place, you will see the data prior to the write, until the row change is committed.

But really, you don't want JDBC's semantics for this, you want the underlying db's implementation of how it works.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic