File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Threads and Synchronization and the fly likes This statement has been closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "This statement has been closed" Watch "This statement has been closed" New topic
Author

This statement has been closed

Surender Suri
Ranch Hand

Joined: May 28, 2010
Posts: 42
Hello,

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..

com.app.iqe.utils.ExceptionAdapterException: org.postgresql.util.PSQLException: This ResultSet is closed.
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.checkClosed(AbstractJdbc2ResultSet.java:2654)
at org.postgresql.jdbc2.AbstractJdbc2ResultSet.next(AbstractJdbc2ResultSet.java:1786)
at org.apache.commons.dbcp.DelegatingResultSet.next(DelegatingResultSet.java:168)
at com.app.iqe.persistence.PersistentManager.processQuery(PersistentManager.java:862)

com.app.iqe.utils.ExceptionAdapterException: org.postgresql.util.PSQLException: This statement has been closed.
at org.postgresql.jdbc2.AbstractJdbc2Statement.checkClosed(AbstractJdbc2Statement.java:2512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.getMaxRows(AbstractJdbc2Statement.java:607)
at org.postgresql.jdbc3.Jdbc3Statement.createResultSet(Jdbc3Statement.java:36)
at org.postgresql.jdbc2.AbstractJdbc2Statement$StatementResultHandler.handleResultRows(AbstractJdbc2Statement.java:211)
at org.postgresql.core.v3.QueryExecutorImpl$1.handleResultRows(QueryExecutorImpl.java:437)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1796)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at org.apache.commons.dbcp.DelegatingStatement.executeQuery(DelegatingStatement.java:205)
at com.app.iqe.persistence.PersistentManager.processQuery(PersistentManager.java:846)

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 ?

Thanks,
Suri

Thanks,
Suri
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1044
    
  10

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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This statement has been closed