ResultSet

Olá

PReciso ter uma ResultSetdentro de outra… separadamente, elas funcionam legal, mas juntas dá pau…

abaixo, o código…

[code] <%
String strPrimeiro = request.getParameter(“strPrimeiro”);
String strSegundo = request.getParameter(“strSegundo”);

// int teste1 = 20;
// int teste2 = 40;

ResultSet rs = lista.geraRelatorio(strPrimeiro, strSegundo);

while(rs.next()){

 String idFerramenta= rs.getString("idferramenta");

ResultSet rs1 = lista.buscaNomeFerramenta(idFerramenta);

while(rs1.next()){
String strNomeFerramenta = rs1.getString(“nomenclatura”);
String strPn = rs1.getString(“pn”);

String codigo = rs.getString(“idferramenta”) + rs.getString(“id”) + rs.getString(“numpainel”);
%>


<%=codigo%> <% } rs1.close(); } rs.close(); %>[/code]

O erro acusado é:

[quote]Exception Details: javax.servlet.ServletException
Este ResultSet está fechado.[/quote]

Alguma dica?!

Ah, tentei tirar o .close() das ResultSet, pro caso de ele estar fechando fora de hora, mas nem assim funcionou…

Valeuuuuu

:shock:

bem tente mudar a declaração de ResultSet rs1 mudando para

[code]while(rs.next()){

 idFerramenta= rs.getString("idferramenta");

rs1 = lista.buscaNomeFerramenta(idFerramenta);[/code]

nao declare os atributos dentro do while

String strNomeFerramenta = rs1.getString(“nomenclatura”);
String strPn = rs1.getString(“pn”);

bem nao sei se ajudei mto mais dei umas dicas hehehe :slight_smile:

Não entendo o pq de ter que usar os 2 métodos?? geraRelatorio e buscaNomeFerramenta

Não é mais fácil fazer uma consulta só com um JOIN??

E não passe um RS como retorno de um método… O melhor é abrir e fechar ResultSets o mais rápido possível, pois enquanto ele estiver aberto, a conexão com o BD está aberta…