Different types of locks in JDBC

What are the different types of locks in JDBC? Explain them

A lock is a preventive software mechanism that other users can not use the data resource.

The types of locks in JDBC:

1. Row and Key Locks:
Useful when updating the rows (update, insert or delete operations), as they increase concurrency.

2. Page Locks:
Locks the page when the transaction updates or inserts or deletes rows or keys. The database server locks the entire page that contains the row. The lock is made only once by database server, even more rows are updated. This lock is suggested in the situation where large number of rows is to be changed at once.

3. Table Locks:
Utilizing table locks is efficient when a query accesses most of the tables of a table. These are of two types:
a) Shared lock:
One shared lock is placed by the database server, which prevents other to perform any update operations.

b) Exclusive lock:
One exclusive lock is placed by the database server, irrespective of the number of the rows that are updated.

4. Database Lock:
In order to prevent the read or update access from other transactions when the database is open, the database lock is used.
How are Observer and Observable used in Java?
All the objects which are the instances of the sub class Observable, maintains a list of observers...
What is synchronization and why is it important in Java?
Synchronization is the process of allowing threads to execute one after another...
Difference between preemptive scheduling and time slicing in Java
Preemptive scheduling enables the highest priority task execution until waiting or dead states entered...
Post your comment