title: Updating multiple tables in MySQL using transactions
body: <p>In java if I want to insert data in multiple tables of same database as transaction then should I use same connection or create connection per table ?</p>
  
  <pre><code>insertInTable(){
  
  insetInTable1();
  insertInTable2()
  
  }
  
  insetInTable1(){
  //get new connection , insert commit
  }
  
  insetInTable2(){
  //get new connection , insert commit
  }
  </code></pre>
  
  <p>Or </p>
  
  <pre><code>insertInTable(){
  
  Connection conn = getConnection();
  insetInTable1(conn);
  insertInTable2(conn)
  
  conn.commit();
  }
  
  insetInTable1(Connection conn){
  //insert
  }
  
  insetInTable2(Connection conn ){
  //insert 
  }
  </code></pre>
  
  <p>Say both tables are in same database .</p>
  
  <p>Is it OK to send same connection across methods ? </p>