Forums Register Login

Difference between Single phase and two phase commit

+Pie Number of slices to send: Send
Can anybody plz explain me the difference between a single phase and two phase commit. which type of commit does JDBC uses.
+Pie Number of slices to send: Send
The two-phase commit (also known as "2PC") means that the transaction manager first sends out a "prepare for commit" message to all participants and starts waiting for acknowledgement messages. Once the owner has received "OK" from every participant, it sends out a "commit" message. If it didn't receive an OK from some participant, it sends out a "rollback" message to all participants. When talking about a single phase commit, the transaction manager only sends out one message, "commit".
The reason why 2PC is needed is distributed transactions. For example, you might have two separate databases being modified within a single transaction. If we have committed the first modification but the second fails, there's no way to rollback the first one anymore.
For a better and more thorough/accurate explanation for 2PC, consult Google.
As to your question about which of these is JDBC using, it uses both. At least in theory. If you have an XA-capable JDBC driver, it should be able to implement the 2PC protocol as well as the normal single-phase commit protocol.
Where does a nanny get ground to air missles? Protect this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 12565 times.
Similar Threads
Single Phase and Two Phase Commit, 3 phase commit
Unable to commit connection in global Tran
Data Source Vs Transaction Data Source
Transactions with Stored Procedures
Two-phase commit using EJB
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 16:59:34.