Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Recordset inside a recordset?

 
Martin Hansson
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 567
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Martin Hansson
Greenhorn
Posts: 7
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx,
It solved my problem!
// Best Regards
// Martin!
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic