wood burning stoves 2.0*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
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: 17249

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") );//
Consider Paul's rocket mass heater.
subject: database
Similar Threads
prepared statement with "in" predicate
intersolv JDBC driver for DB2 on OS/390
How can i continue executing other SQL Statments , even if one of them fails
help connecting to mysql database