pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Oliver Jowett <oliver@opencloud.com>
To: taktos <taktos@gmail.com>
Cc: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: commit and rollback don't throw exceptions when	 they should
Date: Thu, 22 Oct 2009 21:22:36 +1300
Message-ID: <4AE0164C.5010805@opencloud.com> (raw)
In-Reply-To: <4AE00316.8030107@gmail.com>
References: <4ADDCCE1020000250002BBEA@gw.wicourts.gov>
	<4ADF0210.4010100@opencloud.com>
	<4ADED72A020000250002BC40@gw.wicourts.gov>
	<4ADF85C8.6040408@opencloud.com>
	<4AE00316.8030107@gmail.com>

taktos wrote:
> I made a groovy code that tests whether Connection#commit() throws 
> excepton when connection has been closed.
> 
> http://github.com/taktos/JDBC-Driver-Test/blob/master/ConnectionTest.groovy
> 
> I tested in environment below:
> Oracle 10g XE (ojdbc14.jar and ojdbc6.jar)
> MySQL 5.1 (mysql-connector-java-5.1.10.jar)
> h2database (h2-1.2.121.jar)
> PostgreSQL 8.3 (postgresql-8.3.605.jdbc4.jar)
> 
> Drivers other than PosrgreSQL throws exception as I had expected, but 
> PostgreSQL didn't throw exception.

Yes, that is the case I mentioned where there have been no commands 
executed in the transaction. In that case, the driver has no work to do 
on commit() so it does not notice the connection was closed.

Even if we added a check for an explicit Connection.close() call before 
Connection.commit(), that would not help with your test where you are 
shutting down the server. The driver will only notice the network 
connection is gone when it next tries to actually send or receive data.

Try adding a simple query ("SELECT 1", or whatever) to your test, and 
you should see an exception on close.

-O



view thread (12+ messages)  latest in thread

Message-ID: <4AE0164C.5010805@opencloud.com>
Permalink:  ../4AE0164C.5010805@opencloud.com/
Also on:    postgresql.org/message-id/4AE0164C.5010805@opencloud.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: oliver@opencloud.com, taktos@gmail.com, Kevin.Grittner@wicourts.gov
  Subject: Re: commit and rollback don't throw exceptions when	 they should
  In-Reply-To: <4AE0164C.5010805@opencloud.com>
  References: <4ADDCCE1020000250002BBEA@gw.wicourts.gov> <4ADF0210.4010100@opencloud.com> <4ADED72A020000250002BC40@gw.wicourts.gov> <4ADF85C8.6040408@opencloud.com> <4AE00316.8030107@gmail.com> <4AE0164C.5010805@opencloud.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox