On 05/31/2011 08:18 PM, Craig Ringer wrote:
> On 06/01/2011 01:07 AM, Emi Lu wrote:
>> When update/insert/delete is called, always got:
>> ### Error committing transaction. Cause:
>> org.postgresql.util.PSQLException: Cannot commit when autoCommit is
> Sounds like MyBatis expects autocommit to be disabled because it does
> its own explicit BEGIN/COMMIT, but you've got it turned on. The newer
> JDBC driver detects this and complains about it, where the older one
> presumably ignored a COMMIT issued while in autocommit mode.
Thank you for clearing it, and I will use jdbc9.
> Add "autoCommit=false" to your connection parameters.
> "autoCommit" doesn't appear to be documented in
> , which is surprising.
As Oliver said, it's a datasource parameter. The hidden part that is
nowhere to find is "how to configure SpringFramework + mybatis + JDBC9"
to autoCommit = false.
It's just a simple set for me, but it seems there is no easy and
explicit way for user to specify it in the spring_config.xml file.
As an alternative for now, I did:
SqlSession sql_session = sqlSessionFactory.openSession(false); //in
mybatis doc, this line should auto Disable commit, but not indeed!
Connection conn = sql_session.getConnection(); //newly added
conn.setAutoCommit(false); //newly added
conn.commit(); //newly added
conn.close(); //newly added
The above codes work fine. Before I can find a simple way to set
autoCommit=false in spring_config.xml, I will do this way.
Thanks alot for explanation!
In response to
pgsql-jdbc by date
|Next:||From: Tom Lane||Date: 2011-06-01 14:11:11|
|Subject: Re: Mixed up protocol packets in server response? |
|Previous:||From: Michal Politowski||Date: 2011-06-01 13:06:49|
|Subject: Mixed up protocol packets in server response?|