Search code examples
netbeansresultset

Netbeans Java Storing ResultSet In Variable


I'm using Netbeans and I want to store ResultSet results into an Integer variable, may I know if it is possible?

Currently I'm trying all sorts of ways to store it in a variable so I can use it for comparison on the JSP page itself.

            <%
            int no=1;

            while(rst.next()){


            %>
            <tr>
              <td><%=no%></td>

                  <td><%=rst.getString("VERIFYCODE")%></td>

                  <%String code= request.getParameter("name"); %>

                  <%if(rst.getString("VERIFYCODE")== code){

                                  //return a true/false if possible, or redirect to another jsp page

                              }

Solution

  • If you want to get an Integer value from ResultSet, just use rst.getInt("VERIFYCODE") method or Integer.parseInt(rst.getString("VERIFYCODE")).