複数のプリペアドステートメントがあります。すべてのステートメントに対して「connection.commit」を実行する必要がありますか、それとも最後のステートメントの後に1回だけ呼び出す必要がありますか?
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();
ありがとう。