pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Hannes Erven <hannes@erven.at>
To: pgsql-jdbc@postgresql.org
Subject: executeQuery() throws "Statement has been closed"
Date: Thu, 31 Jul 2014 10:56:09 +0200
Message-ID: <53DA04A9.2030101@erven.at> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hi everyone,


sometimes my application (jdbc-1101, hibernate, desktop application) 
reports the following "Statement has been closed" error:


Caused by: org.postgresql.util.PSQLException: Die Anweisung wurde 
geschlossen.
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement.checkClosed(AbstractJdbc2Statement.java:2631)
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement.getMaxRows(AbstractJdbc2Statement.java:659)
	at 
org.postgresql.jdbc4.Jdbc4Statement.createResultSet(Jdbc4Statement.java:34)
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler.handleResultRows(AbstractJdbc2Statement.java:219)
	at 
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1839)
	at 
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:559)
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
	at 
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:302)
	at 
org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)
	... 19 more



When looking at the code of getMaxRows() 
(https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/jdbc2/AbstractJdbc2Statement.java 
line 665):

     public int getMaxRows() throws SQLException
     {
         checkClosed();
         return maxrows;
     }


... I'm wondering why there is even checkClosed() called before 
returning the value of a field?
Could that check be safely removed?

It may be the case that there are concurrent calls from multiple threads 
to the same Connection object, but shouldn't that be thread-safe?

(Un)fortunately the exception is logged very seldomly, so there has not 
yet a pattern emerged when they happen.


Thanks for your comments,
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



view thread (10+ messages)  latest in thread

Message-ID: <53DA04A9.2030101@erven.at>
Permalink:  ../53DA04A9.2030101@erven.at/
Also on:    postgresql.org/message-id/53DA04A9.2030101@erven.at

 · 

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: hannes@erven.at
  Subject: Re: executeQuery() throws "Statement has been closed"
  In-Reply-To: <53DA04A9.2030101@erven.at>
  References: <53DA04A9.2030101@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