executeQuery() throws "Statement has been closed"

Поиск
Список
Период
Сортировка
От Hannes Erven
Тема executeQuery() throws "Statement has been closed"
Дата
Msg-id 53DA04A9.2030101@erven.at
обсуждение исходный текст
Ответы Re: executeQuery() throws "Statement has been closed"  (Dave Cramer <pg@fastcrypt.com>)
Re: executeQuery() throws "Statement has been closed"  (Kevin Grittner <kgrittn@ymail.com>)
Список pgsql-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


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Dennis Gesker
Дата:
Сообщение: Re: XA transaction -- Linux v Windows
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: executeQuery() throws "Statement has been closed"