Re: commit and rollback don't throw exceptions when they should - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: commit and rollback don't throw exceptions when they should
Date
Msg-id 4ADF85C8.6040408@opencloud.com
Whole thread Raw
In response to Re: commit and rollback don't throw exceptions when they should  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: commit and rollback don't throw exceptions when they should  (taktos <taktos@gmail.com>)
List pgsql-jdbc
Kevin Grittner wrote:

> I need to go back and see if any earlier versions conflict with this,
> but recent version of the Java API specify that commit and rollback
> should throw a SQLException if autoCommit is true.  The driver
> currently returns without any warning or exception, and without doing
> anything.

Sounds reasonable.

> Java 6 also explicitly mentions that an exception should be
> thrown for attempts to use these methods on a closed connection,
> although that could arguably fall under the earlier language requiring
> an exception when "a database access error occurs" -- since you can't
> access a database across a closed connection.

Taking a quick look at the code, the driver should already throw an
exception on closed connection if any communication with the server is
actually needed (if autocommit is on or if no commands have been
executed in the current transaction, then it doesn't do any
communication and you won't get an exception). Putting an explicit check
for a closed connection wouldn't hurt.

-O

pgsql-jdbc by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: commit and rollback don't throw exceptions when they should
Next
From: Steve Waldman
Date:
Subject: deadlocks on JDBC batch inserts into tables with many columns