i’m founding a solution of checking the empty resultset… here is the code
temp = rs1;
boolean hasRows = temp.next();
if (hasRows) {
while (rs1.next()) {
String pid = rs1.getString("pid");
System.out.println(pid);
String pd = rs1.getString("description");
double price = rs1.getDouble("price");%>
<br>
Product id : <%=pid %><br>
Description : <%=pd %><br>
Price : <%=price %>
<%
}
}
it seems that temp.next() will affect rs.next(), the result can’t be printed out finally. Why?
next()method already checks the control that you try. If result setrs1has elements the loop will be entered.You don’t seem to use
tempanywhere. Why? Abandon it and get your job done, try this: