This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes Recordset inside a recordset? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Recordset inside a recordset?" Watch "Recordset inside a recordset?" New topic
Author

Recordset inside a recordset?

Martin Hansson
Greenhorn

Joined: Nov 09, 2001
Posts: 7
Hi,
When I query data...
query = "";
query = query + " SELECT *";
query = query + " FROM sdg.tbllocation";
ResultSet rs = stmt.executeQuery(query);

if (rs == null) {
out.println("No database connection");
} else if (rs.next()) {
}
rs.close();
stmt.close();
con.close();
and then try to open another recordset inside the record...
else if (rs.next()) {
query = "";
query = query + " SELECT *";
query = query + " FROM sdg.tblLanguage";
ResultSet rs2 = stmt.executeQuery(query);

if (rs2 == null) {
out.println("No database connection");
} else if (rs2.next()) {
}
rs2.close();
}
...
Then I get...
com.ibm.servlet.engine.webapp.WebAppErrorReport: class com.ibm.ejs.cm.proxy.ResultSetProxy is closed
Does anyone know why?
// Thx
Adam Hardy
Ranch Hand

Joined: Oct 09, 2001
Posts: 565
Yes, you closed your result set by requesting a new one from the statement.
you can get around this by 3 methods:
- improve your sql (if your tables have data that relates to each other)
- instantiate a second statement
- copy your data from the first result set into an array, list or vector before requesting your second result set

I'd try the first, but you didn't specify any fields in your example so it's difficult to tell in your case
Adam


I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.
Martin Hansson
Greenhorn

Joined: Nov 09, 2001
Posts: 7
Thx,
It solved my problem!
// Best Regards
// Martin!
 
 
subject: Recordset inside a recordset?
 
Similar Threads
another array problem
Login code
multiple processes... only want one
ResultSet Thru ResultSet
Oracle clob?