Connection setAutoCommit()

Поиск
Список
Период
Сортировка
От Michael Paesold
Тема Connection setAutoCommit()
Дата
Msg-id 035d01c26c05$0265af90$4201a8c0@beeblebrox
обсуждение исходный текст
Ответ на ResultSet Column Name Problem in pgjdbc2.jar?  (Mike Abraham <mike@firehosesoftware.com>)
Список 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 по дате отправления:

Предыдущее
От: Barry Lind
Дата:
Сообщение: Re: ResultSet Column Name Problem in pgjdbc2.jar?
Следующее
От: Thomas O'Dowd
Дата:
Сообщение: Re: JDBC and commit problems