jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "database" Watch "database" New topic


Relu Ovidiu

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);
//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

Joined: Feb 05, 2001
Posts: 17271

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.

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") );//
Have you checked out Aspose?
subject: database
It's not a secret anymore!