//手动回滚
SqlMapClient sqlMapClient = null;
try {
sqlMapClient = this.getSqlMapClient();
sqlMapClient.startTransaction();
sqlMapClient.getCurrentConnection().setAutoCommit(false);
sqlMapClient.startBatch();
String statement = "abc.def";
HashMap<String, String> hm = new HashMap<String, String>();
String[] guidArr = guids.split(",");
for(String guid : guidArr) {
hm.put("guid", guid);
sqlMapClient.update(statement, hm);
}
sqlMapClient.executeBatch();
sqlMapClient.getCurrentConnection().commit();
sqlMapClient.commitTransaction();
} catch (SQLException e) {
try {
sqlMapClient.getCurrentConnection().rollback();
} catch (SQLException e1) {
e1.printStackTrace();
}
e.printStackTrace();
result = false;
} finally {
try {
sqlMapClient.getCurrentConnection().setAutoCommit(true);
sqlMapClient.endTransaction();
} catch (SQLException e) {
result = false;
}
}
因为之前
sqlMapClient.getCurrentConnection().setAutoCommit(false);
sqlMapClient.startBatch();
的位置颠倒,导致sqlMapClient.getCurrentConnection()得到null