很简单的,就是设置,提交, 回滚了。 connection.setAutoCommit(false);
strSql = "update .. "; connection.executeSql(strSql); strSql = "insert into one ";
System.out.println(strSql);
connection.executeSql(strSql); strSql = " insert into two";
connection.executeSql(strSql);
connection.commit();
}
}
catch ( Exception e )
{
connection.rollback();
throw new SQlException("....");
}
strSql = "update .. "; connection.executeSql(strSql); strSql = "insert into one ";
System.out.println(strSql);
connection.executeSql(strSql); strSql = " insert into two";
connection.executeSql(strSql);
connection.commit();
}
}
catch ( Exception e )
{
connection.rollback();
throw new SQlException("....");
}
其中的 rs.close() stmt.close() connection.close()这些放try{ } 里面的吗?//
多个SQL语句使用同一个statement吗?