Re: "postgresql-9.0-801.jdbc4.jar" always cause "org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled" Exception - Mailing list pgsql-general

From Emi Lu
Subject Re: "postgresql-9.0-801.jdbc4.jar" always cause "org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled" Exception
Date
Msg-id 4DE52DEF.70307@encs.concordia.ca
Whole thread Raw
In response to Re: "postgresql-9.0-801.jdbc4.jar" always cause "org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled" Exception  ("David Johnston" <polobo@yahoo.com>)
Responses Re: "postgresql-9.0-801.jdbc4.jar" always cause "org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled" Exception  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
David,

>> SqlSession sql_session = sqlSessionFactory.openSession(false);
>> ....
>> sql_session.commit();
>>
>
> We'll presume that you intend (intentionally or otherwise) for auto-commit
> to be on since you do not reference any actual JDBC method calls here...

I'd like always "autocommit = false"

jdbc8.4 does keep autocommit= false;

While 9.0 set default autocommit = true -> this is NOT what I want.

Setup is in spring configuration file:
=========================================
applicationContext-mybatis.xml

<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
       <property name="driverClassName" value="${driverClassName}" />
       <property name="url"             value="${url}"      />
       <property name="username"        value="${username}" />
       <property name="password"        value="${password}" />
</bean>

mybatis does not have a parameter needed for autoCommit=false. The
default is false for JDBC8.4 driver.


>> While for "8.4-702 JDBC 4", the same codes, no error at all.

> Arguably 8.4-702 was the bugged version and 9.0-801 corrects the behavior -
> or rather enforces the fact you should not be in auto-commit mode AND
> committing manually.

For Spring3.0.5 + mybatis3 + jdbc9, how do you setup autoCommit = false?

The default for 8.4 is false, while jdbc9 always get "Cannot commit when
autoCommit is enabled" Exception". Where should I specify autoCommit =
false for jdbc9 in spring frame work?


> I would recommend disabling auto-commit and leaving your commit() calls in
> place.

This is exactly what I had and I need for jdbc9 as well. But jdbc9
returns autoCommit = true ?




> explicitly instead of relying upon the driver to do it for you; though there
> are always exceptions but you should code is so that you can request an
> auto-commit session when you know you need one.

Exactly.

I need to know in spring3.0.5 + mybatis + jdbc9 where to setup
autocommit= false.

For spring3.0.5 + mybatis + jdbc8, the default is autocommit = false.

Thank you,
Emi


pgsql-general by date:

Previous
From: "David Johnston"
Date:
Subject: Re: "postgresql-9.0-801.jdbc4.jar" always cause "org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled" Exception
Next
From: "David Johnston"
Date:
Subject: Re: Some clarification about TIMESTAMP