title: how do we do pre commit in java
body: <p>In two phase commit, we will encounter this scenario.</p>
  
  <p>In two phase commit, commit or rollback is done by two phases:</p>
  
  <ol>
  <li>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.</li>
  <li>Commit phase: according to vote if all the votes are yes then commit is done.</li>
  </ol>
  
  <p>Similarly when any transaction changes multiple database after execution of transaction it will issue <strong>pre commit</strong>  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.</p>