con.setAutoCommit(false)自动提交关闭为什么还是不行

qq_40442066 2017-09-29 02:49:26
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());
}
}
...全文
328 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_40442066 2017-09-29
  • 打赏
  • 举报
回复
求大神指点啊

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧