pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feed"postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
6+ messages / 4 participants
[nested] [flat]
* "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
@ 2011-05-31 17:07 Emi Lu <emilu@encs.concordia.ca>
2011-06-01 00:18 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Craig Ringer <craig@postnewspapers.com.au>
0 siblings, 1 reply; 6+ messages in thread
From: Emi Lu @ 2011-05-31 17:07 UTC (permalink / raw)
To: pgsql-jdbc
Hello list,
. Postgresql8.3
. mybatis-3.0.5-SNAPSHOT.jar
. mybatis-spring-1.0.1-SNAPSHOT.jar
. spring3.0.5
. postgresql-9.0-801.jdbc4.jar
SqlSession sql_session = sqlSessionFactory.openSession(false);
....
sql_session.commit();
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>
When update/insert/delete is called, always got:
===================================================
### Error committing transaction. Cause:
org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
While for "8.4-702 JDBC 4", the same codes, no error at all.
Is there anything need to be configured if using
"postgresql-9.0-801.jdbc4.jar"?
Thanks a lot!
Emi
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
2011-05-31 17:07 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
@ 2011-06-01 00:18 ` Craig Ringer <craig@postnewspapers.com.au>
2011-06-01 00:53 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Oliver Jowett <oliver@opencloud.com>
2011-06-01 13:55 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
0 siblings, 2 replies; 6+ messages in thread
From: Craig Ringer @ 2011-06-01 00:18 UTC (permalink / raw)
To: emilu@encs.concordia.ca; +Cc: pgsql-jdbc
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
> enabled.
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.
Add "autoCommit=false" to your connection parameters.
"autoCommit" doesn't appear to be documented in
http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters
, which is surprising.
--
Craig Ringer
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
2011-05-31 17:07 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
2011-06-01 00:18 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Craig Ringer <craig@postnewspapers.com.au>
@ 2011-06-01 00:53 ` Oliver Jowett <oliver@opencloud.com>
1 sibling, 0 replies; 6+ messages in thread
From: Oliver Jowett @ 2011-06-01 00:53 UTC (permalink / raw)
To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: emilu@encs.concordia.ca; pgsql-jdbc
On 1 June 2011 12:18, Craig Ringer <craig@postnewspapers.com.au> wrote:
> "autoCommit" doesn't appear to be documented in
> http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters
> , which is surprising.
It's a datasource parameter, not a connection parameter.
Possibly mybatis is trying to handle the old datasource default that
had autocommit=false for connections obtained from a datasource.
That default was changed quite a long time ago.
Oliver
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
2011-05-31 17:07 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
2011-06-01 00:18 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Craig Ringer <craig@postnewspapers.com.au>
@ 2011-06-01 13:55 ` Emi Lu <emilu@encs.concordia.ca>
1 sibling, 0 replies; 6+ messages in thread
From: Emi Lu @ 2011-06-01 13:55 UTC (permalink / raw)
To: Craig Ringer <craig@postnewspapers.com.au>; +Cc: pgsql-jdbc@postgresql.org, Craig Ringer <craig@postnewspapers.com.au>
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
>> enabled.
>
> 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
> http://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters
> , 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
try
{
conn.setAutoCommit(false); //newly added
....
conn.commit(); //newly added
sql_session.commit();
}catch(...){}
finally
{
try{
conn.close(); //newly added
} ...
try
{
sql_session.close();
}
}
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!
Emi
^ permalink raw reply [nested|flat] 6+ messages in thread
* "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
@ 2011-05-31 18:11 Emi Lu <emilu@encs.concordia.ca>
2011-05-31 22:42 ` Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Dave Cramer <pg@fastcrypt.com>
0 siblings, 1 reply; 6+ messages in thread
From: Emi Lu @ 2011-05-31 18:11 UTC (permalink / raw)
To: pgsql-jdbc
Hello list,
JDBC8 returns autocommit = false; which is what I want.
But when I upgrade to JDBC9, I got:
===================================================
### Error committing transaction. Cause:
org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
Is there anything need to be configured if using
"postgresql-9.0-801.jdbc4.jar" to set autocommit = false always?
I use springframework3.0.5 + mybatis3 to setup DB connections:
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>
This codes return autocommit= false for JDBC8; while JDBC9 returns
autocommit=true as default.
Thanks a lot!
Emi
---
. Postgresql8.3
. mybatis-3.0.5-SNAPSHOT.jar
. mybatis-spring-1.0.1-SNAPSHOT.jar
. spring3.0.5
. postgresql-9.0-801.jdbc4.jar
SqlSession sql_session = sqlSessionFactory.openSession(false);
....
sql_session.commit();
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception
2011-05-31 18:11 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
@ 2011-05-31 22:42 ` Dave Cramer <pg@fastcrypt.com>
0 siblings, 0 replies; 6+ messages in thread
From: Dave Cramer @ 2011-05-31 22:42 UTC (permalink / raw)
To: emilu@encs.concordia.ca; +Cc: pgsql-jdbc
On Tue, May 31, 2011 at 2:11 PM, Emi Lu <emilu@encs.concordia.ca> wrote:
> Hello list,
>
> JDBC8 returns autocommit = false; which is what I want.
>
> But when I upgrade to JDBC9, I got:
> ===================================================
> ### Error committing transaction. Cause:
> org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled.
>
> Is there anything need to be configured if using
> "postgresql-9.0-801.jdbc4.jar" to set autocommit = false always?
>
> I use springframework3.0.5 + mybatis3 to setup DB connections:
>
> 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>
>
>
> This codes return autocommit= false for JDBC8; while JDBC9 returns
> autocommit=true as default.
>
>
> Thanks a lot!
> Emi
> ---
>
> . Postgresql8.3
>
> . mybatis-3.0.5-SNAPSHOT.jar
> . mybatis-spring-1.0.1-SNAPSHOT.jar
> . spring3.0.5
>
> . postgresql-9.0-801.jdbc4.jar
>
>
> SqlSession sql_session = sqlSessionFactory.openSession(false);
> ....
> sql_session.commit();
>
>
>
>
As far as I know autocommit should be enabled by default in both instances.
Can you get the server logs ?
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2011-06-01 13:55 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-31 17:07 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
2011-06-01 00:18 ` Craig Ringer <craig@postnewspapers.com.au>
2011-06-01 00:53 ` Oliver Jowett <oliver@opencloud.com>
2011-06-01 13:55 ` Emi Lu <emilu@encs.concordia.ca>
2011-05-31 18:11 "postgresql-9.0-801.jdbc4.jar" Causing "Error committing transaction. Cause: org.postgresql.util.PSQLException: Cannot commit when autoCommit is enabled." Exception Emi Lu <emilu@encs.concordia.ca>
2011-05-31 22:42 ` Dave Cramer <pg@fastcrypt.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox