title: jdbc - executing multiple statements with commit
body: <p>I have multiple prepared statements. Do I need to execute 'connection.commit' for every statement or call only once after the last statement?</p>
  
  <pre><code>Connection connection = datasource.getConnect();
  connection.setAutoCommit(false);
  PreparedStatement pstmt1 = connection.prepareStatement(query1);
  pstmt1.executeUpdate();
  connection.commit();
  
  PreparedStatement pstmt2 = connection.prepareStatement(query2);
  pstmt2.executeUpdate();
  connection.commit();
  
  PreparedStatement pstmt3 = connection.prepareStatement(query3);
  pstmt3.executeUpdate();
  connection.commit();
  
  
  Or
  
  Connection connection = datasource.getConnect();
  connection.setAutoCommit(false);
  PreparedStatement pstmt1 = connection.prepareStatement(query1);
  pstmt1.executeUpdate();
  
  PreparedStatement pstmt2 = connection.prepareStatement(query2);
  pstmt2.executeUpdate();
  
  PreparedStatement pstmt3 = connection.prepareStatement(query3);
  pstmt3.executeUpdate();
  
  connection.commit();
  </code></pre>
  
  <p>Thanks.</p>