Hi,
I would like to learn about the locking issue in databases.
Firstly two concepts:
1) Pessimistic Locking through FOR UPDATE usage in SELECT statements: We can use this in our transactions, start the transaction, do the select-> you have the record locking with the FOR UPDATE, so nobody can select this record, do your operations on this record, commit-> Lock has finished. Am I right?
2) Optimistic Locking: I dont know how to enable this, but what happens is as follows: In an UPDATE statement on a row(record), if another update is issued before than yours, your UPDATE returns a result of 0 which means the record isnot updated. So if we use this in a transaction like;
select and show the result
update the record
commit
the select may have shown an incorrect value because after the select someone can UPDATE our record before our UPDATE runs. Am I correct? Also how do we enable Optimistic Locking?
Also there are the locking issues in the
SCJD certification which is independent from the Databases, implemented by the user? Read Write Locks, Can you write on them?
Also there are locking issues through the Transaction Isolation Levels? Do they work for all of the DBs we reach with
JDBC? Can we trust them? If we can use them, do we need the others?
Thanks in advance.
Best regards...