One more tough JDBC question to understand and prepare. There are 2 types of locking in JDBC by which we can handle multiple user issue using the record. if two user are reading the same record then there is no issue but what if users are updating the record , in this case changes done by first user is gone by second user if he also update the same record .so we need some type of locking so no lost update.
Optimistic Locking: optimistic locking lock the record only when update take place. Optimistic locking does not use exclusive locks when reading
Pessimistic locking: in this record are locked as it selects the row to update