This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

This statement has been closed  RSS feed

Surender Suri
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am not sure if this is the right section to ask this question. Anyway it is related partly with multi-threading.

We have a web application running on tomcat, using dbcp (1.2) for connection pooling. Our application is heavely multi-threaded and is working fine with no issues, but recently we added a new flow where we are using similar multi threading as in rest of our app and we started seeing below issue consistently.. It does not happen if the new request runs in single thread.. org.postgresql.util.PSQLException: This ResultSet is closed.
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(
at org.postgresql.util.PSQLException: This statement has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Statement.checkClosed(
at org.postgresql.jdbc2.AbstractJdbc2Statement.getMaxRows(
at org.postgresql.jdbc3.Jdbc3Statement.createResultSet(
at org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler.handleResultRows(
at org.postgresql.core.v3.QueryExecutorImpl$1.handleResultRows(
at org.postgresql.core.v3.QueryExecutorImpl.processResults(
at org.postgresql.core.v3.QueryExecutorImpl.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(

Below is the sample code of processQuery method.

Nothing is changed with respect to configuration ect.. the rest of the app and flows works fine. I tried with updating the dbcp jar with latest version, but no effect.

Any idea's on what might be causing the issue? is it multi-threading or connection pooling related ?

Richard Tookey
Posts: 1166
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what is causing your problem but I don't understand why you have the code

at all since the 'finally' clause will close the statement and return the connection to the pool! Also, since both 'stmt' and 'conn' are local variables there is no need to set them to null since they will go out of scope as soon as the method exits.

It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!