con.setAutoCommit(false)自动提交关闭为什么还是不行
String Str = "0";
Connection con = null;
Savepoint savepoint = null;
try {
con=isdisplayJdbcTemplate.getDataSource().getConnection();
con.setAutoCommit(false);
savepoint= con.setSavepoint();
String deleteSql ="truncate table search_score_temp";
String insertSql="INSERT INTO SEARCH_SCORE_TEMP (SELECT B.RELEVANT_SID,B.CHANNEL_SID,B.KEY_WORD,B.PERSON_SCORE,B.SYSTEM_SCORE,B.TYPE "+
"FROM (SELECT A.CHANNEL_SID,A.KEY_WORD,A.RELEVANT_SID,A.PERSON_SCORE,A.SYSTEM_SCORE,A.TYPE,"+
"ROW_NUMBER() OVER(PARTITION BY A.CHANNEL_SID, A.KEY_WORD ORDER BY(NVL(A.PERSON_SCORE, 0) + NVL(A.SYSTEM_SCORE, 0)) DESC) RN "+
"FROM SEARCH_RELEVANT_SCORE A where A.Is_Delete = 0 and A.Is_Display = 1) B WHERE RN <= "+limit+")";
this.isdisplayJdbcTemplate.update(deleteSql);
if(true){
throw new Exception("异常测试");
}
this.isdisplayJdbcTemplate.update(insertSql);
con.commit();
con.setAutoCommit(true);
} catch (Exception e) {
Str = "-1";
try {
con.rollback(savepoint);
} catch (Exception e1) {
logger.error("======================"+e1.getMessage());
}
logger.error("======================"+e.getMessage());
}finally{
try {
con.close();
} catch (SQLException e) {
logger.error("======================"+e.getMessage());
}
}