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

resultset is closed problem

deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
rs=st.executeQuery(" "); //first query
while(rs.next())
{
rs1=st.executeQuery(" "); //second query
while(rs1.next())
{
}
}

in above way i write two queries in JSP Pageusing two different Resultset objects
but when i run the program
it shows

"OPERATION NOT ALLWED AFETR RESULTSET IS CLOSED"
now what can i do? how can i remove this problem?
Nicola Garofalo
Ranch Hand

Joined: Apr 10, 2010
Posts: 308
Quoting from ResultSet documentation:


A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, or used to retrieve the next result from a sequence of multiple results.


http://java.sun.com/javase/6/docs/api/java/sql/ResultSet.html

Create a new Statement from the Connection to your database.


Bye,
Nicola
deep raj
Ranch Hand

Joined: Dec 11, 2009
Posts: 186
in nested form
it is not used with different resultset and same statement
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2500
    
    8

The spec says:
A ResultSet object is automatically closed when the Statement object that generated it is closed, re-executed, ...


Your code does:


I think that your Statement object st is re-executed here, hence : ResultSet object is automatically closed.


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: resultset is closed problem