Connection setAutoCommit() - Mailing list pgsql-jdbc

From Michael Paesold
Subject Connection setAutoCommit()
Date
Msg-id 035d01c26c05$0265af90$4201a8c0@beeblebrox
Whole thread Raw
In response to ResultSet Column Name Problem in pgjdbc2.jar?  (Mike Abraham <mike@firehosesoftware.com>)
List pgsql-jdbc
I have just wondered about the implementation of Connection.setAutoCommit().
At least the JDBC 1.3 API has this note:
NOTE: If this method is called during a transaction, the transaction is
committed.

With postgresql that is not the case, at least not for 7.2 of the jdbc
driver:

public void setAutoCommit(boolean autoCommit) throws SQLException
{
        if (this.autoCommit == autoCommit)
                return;
...

It think this is important to be consistent, otherwise it's not possible to
know the transaction state after setAutoCommit()
Any comments?

Another question: is it a generally good idea to start a new transaction
just after every setAutoCommit(), commit() or rollback()? Wouldn't it be
better to "begin;" just before the first statement to be executed? That
wouldn't leave so many open transactions when you have many open
connections.

Regards,
Michael Paesold



pgsql-jdbc by date:

Previous
From: Barry Lind
Date:
Subject: Re: ResultSet Column Name Problem in pgjdbc2.jar?
Next
From: Thomas O'Dowd
Date:
Subject: Re: JDBC and commit problems