fix PG的重复设置事务等级的bug

This commit is contained in:
tianzhenyu 2021-09-28 16:30:39 +08:00
parent 47a83330e6
commit d6cb2e14fb

View File

@ -764,13 +764,18 @@ public abstract class AbstractSQLExecutor implements SQLExecutor {
}
@Override
private boolean setIsolationStatus = false; //设置事务等级
public void begin(int transactionIsolation) throws SQLException {
Log.d("\n\n" + TAG, "<<<<<<<<<<<<<< TRANSACTION begin transactionIsolation = " + transactionIsolation + " >>>>>>>>>>>>>>>>>>>>>>> \n\n");
//不做判断如果掩盖了问题调用层都不知道为啥事务没有提交成功
// if (connection == null || connection.isClosed()) {
// return;
// }
connection.setAutoCommit(false);
if(! this.setIsolationStatus){ //只设置一次Isolation等级 PG重复设置事务等级会报错
connection.setTransactionIsolation(transactionIsolation);
}
this.setIsolationStatus=true;
connection.setAutoCommit(false); //java.sql.SQLException: Can''t call commit when autocommit=true
}
@Override