aspose file tools*
The moose likes JDBC and the fly likes Unable to read resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Unable to read resultset" Watch "Unable to read resultset" New topic
Author

Unable to read resultset

shailesh gupta
Greenhorn

Joined: Jan 24, 2002
Posts: 1
Hi,
I am trying to run a java application on a solaris 8 machine with apache tomcat webserver. Driver is jdbc thin driver type 4 (classes12.zip).
I have a java class that calls a bean(DBControl) for executing a query. This bean has two methods - one for executing normal select queries(getSelestResult) and the other for updating, inserting or deleting rows in the database(getUpdateResult).
Each of these methods in turn calls another bean(DBProcess) with 4 methods - getConnection() for making a connection to the database, doSelect() for executing a normal select query and returning the resultset, doUpdate() for updating, inserting or deleting rows from database and disconnect() for closing the connection to the database.
The doSelect() method is called by the getSelectResult() of DBControl bean only and doUpdate() is called by the getUpdateResult() of DBControl bean only.
The methods for connecting to the database, querying to the database and returning the resultset are called successively in the try block of the two methods in DBControl bean and the disconnect() method is called in the finally block.
On trying to access the returned resultset from the java class, the following error is displayed.
"java.sql.SQLException: Closed Connection: next"
What could be the possible problem? Is it related to closing the connection in the finally block of DBControl bean before the returned resultset could be used?
These beans have worked satisfactorily on linux with apache tomcat webserver and postgresql as the database.
Thanks,
Shailesh.
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
This would best be answered in the JDBC forum. I'm moving it there.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

The connection is most likely closed when the resultset goes out of scope... either by a finally block of the class or explicitly by your code. Can you return a CachedRowSet or ArrayList instead?
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to read resultset