问:如题
try {
conn1.setAutoCommit(false);
conn2.setAutoCommit(false);
Statement stmt1 = conn1.createStatement();
Statement stmt2 = conn2.createStatement();
stmt1.executeUpdate("update jianshe set money=money+100  where id=1");
stmt2.executeUpdate("update gongshang set money=money-100 where id=1");
conn1.commit();
conn2.commit();
} catch (Exception e) {
try {
conn1.rollback();
} catch (SQLException e2) {
LogFile.Writer("LocalHost数据库连接回滚失败", "dberror");
}
try {
conn2.rollback();
} catch (SQLException e1) {
LogFile.Writer("Remote数据库连接回滚失败", "dberror");
}
LogFile.Writer("数据库操作失败", "dberror");
}