You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2020/01/09 04:17:16 UTC

[GitHub] [incubator-shardingsphere] geomonlin commented on issue #3904: Could not roll back JDBC transaction using postgresql in sharding-proxy

geomonlin commented on issue #3904: Could not roll back JDBC transaction using postgresql in sharding-proxy 
URL: https://github.com/apache/incubator-shardingsphere/issues/3904#issuecomment-572377182
 
 
   I used the mybatis but did not set setAutoCommit (false)
   already **set max_prepared_transactions > 0**
   code:
   ` TransactionTypeHolder.set(TransactionType.XA);
           jdbcTemplate.execute(new ConnectionCallback<Object>() {
               @Override
               public Object doInConnection(final Connection connection) throws SQLException, DataAccessException {
                   connection.setAutoCommit(false);
                   doInsert(connection);
                   printData(jdbcTemplate, "----------------- query all before commit ------------------");
                   connection.rollback();
                   printData(jdbcTemplate, "----------------- query all after rollback ------------------");
                   return null;
               }
           });`
   Now. I use row-jdbc and set connection.setAutoCommit(false);
   It appear `org.postgresql.util.PSQLException: Expected command status BEGIN, got .
   	at org.postgresql.core.v3.QueryExecutorImpl$1.handleCommandStatus(QueryExecutorImpl.java:536)
   	at org.postgresql.core.v3.QueryExecutorImpl.interpretCommandStatus(QueryExecutorImpl.java:2492)
   	at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2127)
   	at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:308)
   	at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
   	at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
   	at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:143)
   	at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:120)
   	at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
   	at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
   	at org.apache.shardingsphere.example.transaction.xa.raw.jdbc.ExampleMainPg.doInsert(ExampleMainPg.java:108)
   	at org.apache.shardingsphere.example.transaction.xa.raw.jdbc.ExampleMainPg.access$000(ExampleMainPg.java:37)
   	at org.apache.shardingsphere.example.transaction.xa.raw.jdbc.ExampleMainPg$2.doInConnection(ExampleMainPg.java:91)
   	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:353)
   	at org.apache.shardingsphere.example.transaction.xa.raw.jdbc.ExampleMainPg.process(ExampleMainPg.java:87)
   	at org.apache.shardingsphere.example.transaction.xa.raw.jdbc.ExampleMainPg.main(ExampleMainPg.java:53)`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services