aspose file tools*
The moose likes JDBC and the fly likes Lock while Updating? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Lock while Updating?" Watch "Lock while Updating?" New topic
Author

Lock while Updating?

Gaurav Jain
Ranch Hand

Joined: Mar 11, 2004
Posts: 108
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?
S Herod
Greenhorn

Joined: Apr 25, 2005
Posts: 10
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Lock while Updating?