Search Postgresql Archives

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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: Emi Lu [mailto:emilu@xxxxxxxxxxxxxxxxx]
> Sent: Tuesday, May 31, 2011 2:06 PM
> To: David Johnston
> Cc: pgsql-general@xxxxxxxxxxxxxx
> Subject: Re:  "postgresql-9.0-801.jdbc4.jar" always cause
> "org.postgresql.util.PSQLException: Cannot commit when autoCommit is
> enabled" Exception
> 
> 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

[Note: treat the following as pseudo code, i.e., the syntax may be
incorrect]

Don't know about the framework settings but since you seem to be wrapping
your "getConnection()" and similar calls can you just modify your code to
call "connection.setAutoCommit(false)" prior to returning the connection
instance to the caller?

You may want to ask (or search) on the appropriate framework list/faq since
I would guess this question has been previously asked.  The issue is not
PostgreSQL specific so a PostgreSQL oriented list, even the JDBC one, may
not yield someone who uses the framework in question.

Even if you can setup the framework to default auto-commit if you are not
already wrapping your "getConnection()" calls you'd be wise to consider
doing so.  If you want to toggle auto-commit on a per-request basis you
would want to centralize that particular logic.

I am not sure but you could also turn off auto-commit just before you
"execute()" the statement if you are centralizing that part instead.

I am not familiar with any of the persistence frameworks but your question
HAS to have been asked and answered previously; it is just a matter of
either finding the answer via search or waiting for someone more
knowledgeable to respond.  Otherwise you can at least ponder the
alternatives (getConnection() or execute() centralization) which may be
useful even if you find the more direct solution to this particular problem.

David J.






-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux