• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Recordset inside a recordset?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 567
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx,
It solved my problem!
// Best Regards
// Martin!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic