[EMAIL PROTECTED] wrote:
Cristian Dudila <[EMAIL PROTECTED]> writes:
[EMAIL PROTECTED] wrote:
I want to warn the user if a row is locked in derby database by
another user.
You will get an exception if you try to access that row and your
transaction cannot get the lock within some timeout (which you can
specify, I think).
Note that the lock isn't kept by another user, but
by another transaction. So if you limit the duration of all
transactions accessing this particular row, there should be no need
for a warning...
With TRANSACTION_REPEATABLE_READ using a SELECT we will have a shared
lock in derby, so we can read data but not to change it( in case of
update, from another database connection, we receive an exception that
the lock cannot be obtained ).
Is there a possibility to check in derby if a row is locked( except to
try a dummy UPDATE on that row ) ?
I don't think that will work. If another transaction has locked the
row, your update will just wait for the lock to be released. It will
only give an exception if the lock request times out, I think.
You can dump all locks from a system table (check the manuals for the
details). But even if this shows that the row isn't locked there is no
guarantee that your transaction will get the lock, (another
transaction may beat you to it).
Yes, thanks, you're right, I would like to avoid locking a row in two
steps( check and then lock ), I didn't know that we can dump all
locks.Thanks.
Cristian