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