Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: JSP ResultSet

  1. #1
    New Coder
    Join Date
    Sep 2002
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    JSP ResultSet

    Hi, how do i check that a resultset is empty, or a resultset is not found?? If it is not empty, it will retrieve all the records and display it.

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    rs.next will return a false if you have no more rows to retrieve. If no rows are received then it will return false the first time you call it. If there is a row to get, it retrieves it.

    Here is a sample of code that I use

    <%
    ResultSet rs = stmt.executeQuery(strQry);
    int cntr = 0;
    while(rs.next())
    {
    cntr++; %>
    <tr>
    <td><%= rs.getString("name") %></td>
    <td><%= rs.getString("ssn") %></td>
    <td><%= rs.getDate("rcvd") %></td>
    </tr>
    <% } %>

    So when no rows are retrieved cntr = 0. I print the cntr out once all the rows are read.

    Hope this helps.

    Rita
    Rita P.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •