This is one of the most popular JDBC Interview questions and asked at an advanced level, mostly to senior Java developers on J2EE interviews. Two-phase commit is used in a distributed environment where multiple processes take part in the distributed transaction process. In simple word we can understand like if any transaction is executing and it will affect multiple databases then a two-phase commit will be used to make all database synchronized with each other.
In two-phase commit, commit or rollback is done by two phases:
1. Commit request phase: in this phase main process or coordinator process take vote of all other process that they are complete their process successfully and ready to commit if all the votes are “yes†then they go ahead for next phase. And if “No “then rollback is performed.
2. Commit phase: according to vote if all the votes are yes then commit is done.
Similarly when any transaction changes multiple database after execution of transaction it will issue pre commit command on each database and all database send acknowledgement and according to acknowledgement if all are positive transaction will issue the commit command otherwise rollback is done .
Posted Date:- 2021-09-04 04:50:51
How Do I Start Debugging Problems Related To The Jdbc Api?
What are the parameter types in Stored Procedures?
What is the use of getGeneratedKeys() method in Statement?
How to set NULL values in JDBC PreparedStatement?
List some exceptions that come under SQLException?
What is savepoint and what are the methods we have in JDBC for savepoint?
How to change the auto-commit mode value?
How many packages are available in JDBC API?
What is the function of DriverManager class?
What is the difference between executing, executeQuery, executeUpdate in JDBC?
What do you mean by Metadata and why we are using it?
What are database warnings in JDBC and how can we handle database warnings in JDBC?
Why would you use setAutoCommit(false) in JDBC?
What is the use of JDBC DriverManager class?
What Is The Need Of Batchupdates?
Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?
What do you mean by cold backup, hot backup?
How cursor works in the scrollable result set?
What is the mean of “dirty read“ in database?
How does JDBC API helps us in achieving loose coupling between Java Program and JDBC Drivers API?
What is JDBC API and when do we use it?
Explain the difference between RowSet vs. ResultSet in JDBC?
What Are The Different Types Of Rowset ?
Does The Jdbc-odbc Bridge Support Multiple Concurrent Open Statements Per Connection?
Which Type Of Jdbc Driver Is The Fastest One?
How To Call A Stored Procedure From Jdbc ?
What Are Callable Statements ?
What is the main purpose of the ResultSetMetaData interface?
What Does The Connection Object Represents?
What are the JDBC API components?
Can we get the data of the particular row from the resultset?
What are the concurrency modes in ResultSet?
What is the ResultSet interface?
How to call Stored Procedures in JDBC?
What is DriverManager in JDBC?
What are the steps to connect with JDBC?
What do you mean by DatabaseMetaData and why we are using it?
Which data types are used for storing the image and file in the database table?
Which type of JDBC driver is used by most people?
What are the different types of drivers in JDBC?