PSQLException: current transaction is aborted, commands ignored until end of transaction block

前端 未结 20 1816
借酒劲吻你
借酒劲吻你 2020-12-04 06:51

I am seeing the following (truncated) stacktrace in the server.log file of JBoss 7.1.1 Final:

Caused by: org.postgresql.util.PSQLException: 
ERROR: current t         


        
20条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 07:48

    You need to rollback. The JDBC Postgres driver is pretty bad. But if you want to keep your transaction, and just rollback that error, you can use savepoints:

    try {
    _stmt = connection.createStatement();
    _savePoint = connection.setSavepoint("sp01");
    _result = _stmt.executeUpdate(sentence) > 0;
    } catch (Exception e){
     if (_savePoint!=null){
     connection.rollback(_savePoint);
    }
    }
    

    Read more here:

    http://www.postgresql.org/docs/8.1/static/sql-savepoint.html

提交回复
热议问题