Re: commit and rollback don't throw exceptions when they should

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>
Cc: taktos(at)gmail(dot)com, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: commit and rollback don't throw exceptions when they should
Date: 2009-10-21 22:06:00
Message-ID: 4ADF85C8.6040408@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Steve Waldman 2009-10-22 06:03:07 deadlocks on JDBC batch inserts into tables with many columns
Previous Message Kevin Grittner 2009-10-21 14:40:58 Re: commit and rollback don't throw exceptions when they should