• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

resultset is closed problem

 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
deep raj
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in nested form
it is not used with different resultset and same statement
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic