aspose file tools*
The moose likes JDBC and the fly likes database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "database" Watch "database" New topic
Author

database

Relu Ovidiu
Greenhorn

Joined: Mar 18, 2004
Posts: 12
I recive this error: " java.sql.SQLException: Operation not allowed after ResultSet closed " when i'm using this code:

----------------
....
String query="select * from table1";
ResultSet rs = stmt.executeQuery(query);
while(rs.next())
{
//i want to make another select...how can a do that?
query="select * from table2 where id_us2=" +rs.getInt("id_u");

ResultSet rs1=stmt.executeQuery(query);//here i recive the error
out.println( rs1.getInt("id_us2") );//
}
.....
So, how can i resolve the problem?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Moving to JDBC forum.
This forum is for Servlets questions.
Also you are using the same statement object that you used in the first place, maybe you need to create another statement object. But his is a guess.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gowrishankar Mudaliar
Ranch Hand

Joined: Oct 20, 2001
Posts: 39
try to have another statement and try this.
ResultSet rs1=new_statement.executeQuery(query);//here i recive the error
out.println( rs1.getInt("id_us2") );//
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: database