Re: Bug: Transaction still open after error when autocommit=true - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Bug: Transaction still open after error when autocommit=true
Date
Msg-id CA+0W9LM4sPezbSQ2t1RukzFFapksLyJsqYw0aw-Z16SOd92tqA@mail.gmail.com
Whole thread Raw
In response to Bug: Transaction still open after error when autocommit=true  (Daniel Migowski <dmigowski@ikoffice.de>)
List pgsql-jdbc
On 23 December 2011 10:09, Daniel Migowski <dmigowski@ikoffice.de> wrote:

> If I send a statement with a BEGIN token

Don't do that; the driver is expecting you to manage transaction
demarcation by using JDBC's autocommit setting and commit/rollback,
not by sending explicit SQL. (Kevin pointed out the relevant JDBC
javadoc that covers this in his reply)

If you must send a raw BEGIN for some reason, then you're also
responsible for transaction cleanup yourself (i.e. don't expect
commit() or rollback() to work; you must send appropriate SQL yourself
to commit or rollback the transaction)

The driver's implementation of autocommit boils down to "if autocommit
is off and the connection does not have an active transaction, then
send BEGIN before the next query". When autocommit is on, the driver
just assumes the server's default behavior - i.e. autocommit happens
without any special intervention. If you send an explicit transaction
demarcation commands, you'll confuse that.

Oliver

pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: Bug: Transaction still open after error when autocommit=true
Next
From: Magosányi Árpád
Date:
Subject: Datasource portNumber property