Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

database

 
Relu Ovidiu
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Gowrishankar Mudaliar
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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") );//
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic