matthewking
Programmer
Hi,
I have a table holding Categories and SubCategories for a menu system. I want to loop through the Categories, running a seperate query for each to extract the subCats for that cat.
heres what im trying at the moment:
This is just returning javax.servlet.ServletException: ResultSet is closed. And I cant seem to figure it out.
Any Solutions? Tips?
Thanks
I have a table holding Categories and SubCategories for a menu system. I want to loop through the Categories, running a seperate query for each to extract the subCats for that cat.
heres what im trying at the moment:
Code:
String query="select CatID, Description, Name, SubCatRef from categories";
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection(url, userName, password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);
while (rs.next())
{
%>
<img src="arrow.gif"> <a href="index.jsp?CatID=<%= rs.getInt("CatID")%>" title="<%= rs.getString("Description")%>"><%= rs.getString("Name")%></a><br>
<%
String innerQuery = "select Name from Categories where SubCatRef='" + rs.getInt("SubCatRef") + "'";
ResultSet Res = stmt.executeQuery(innerQuery);
while (Res.next())
{
%> <%= Res.getString("Name")%> <br> <%
}
%>
<%
}
stmt.close();
con.close();
This is just returning javax.servlet.ServletException: ResultSet is closed. And I cant seem to figure it out.
Any Solutions? Tips?
Thanks