From: Hannes Erven <hannes@erven.at>
To: Dave Cramer <pg@fastcrypt.com>
Cc: List <pgsql-jdbc@postgresql.org>
Subject: Re: executeQuery() throws "Statement has been closed"
Date: Thu, 31 Jul 2014 21:33:31 +0200
Message-ID: <53DA9A0B.6090404@erven.at> (raw)
In-Reply-To: <CADK3HHKUi8DF_R4DAtMOjFEeO5z9aqxtULHZb9iQUqwWRBG3KA@mail.gmail.com>
References: <53DA04A9.2030101@erven.at>
<CADK3HH+9x3Ni8y=KzyUsdsLN5j3cZUcbvjMKC7mmt8o3zCTK3A@mail.gmail.com>
<53DA50FF.2040803@erven.at>
<CADK3HHKUi8DF_R4DAtMOjFEeO5z9aqxtULHZb9iQUqwWRBG3KA@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>
Dave,
> Sharing one connection across multiple hibernate sessions seems
> fraught with danger ?
sorry, I should have explained better. This is a read-only ("SELECT")
workload, so there are no commits etc. interfering between threads. This
is a session-per-view pattern so the indiviual sessions have minimal
size and may be closed and garbage collected independently.
Access to the backend is again pooled through a pgbouncer statement pool
(which might be another place to look at).
According to http://jdbc.postgresql.org/documentation/81/thread.html ,
JDBC connections are threadsafe and can be used by multiple threads
concurrently.
That page also reads,
"If a thread attempts to use the connection while another one is using
it, it will wait until the other thread has finished its current
operation. If the operation is a regular SQL statement, then the
operation consists of sending the statement and retrieving any ResultSet
(in full)."
As I understand it, even if one thread closes the connection, a call to
executeQuery() should either fail early or complete. It appears to me
that is is not the case in these rare instances where the exception is
thrown only when the results have already been processed successfully.
As Kevin pointed out (thanks!), getMaxRows() is required by the spec to
check whether the connection is still open.
So let me rephrase the question: why is
AbstractJdbc4Statement.createResultSet() calling getMaxResult() and
friends [which in turn check for openness] instead of directly using the
already prepared field values?
In any case, I'll see if I can come up with a test case to demonstrate.
Thanks again,
best regards
-hannes
--
Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-jdbc
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: hannes@erven.at, pg@fastcrypt.com
Subject: Re: executeQuery() throws "Statement has been closed"
In-Reply-To: <53DA9A0B.6090404@erven.at>
References: <53DA04A9.2030101@erven.at> <CADK3HH+9x3Ni8y=KzyUsdsLN5j3cZUcbvjMKC7mmt8o3zCTK3A@mail.gmail.com> <53DA50FF.2040803@erven.at> <CADK3HHKUi8DF_R4DAtMOjFEeO5z9aqxtULHZb9iQUqwWRBG3KA@mail.gmail.com> <53DA9A0B.6090404@erven.at>
* 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