number of rows in a resultset


EJB programming & troubleshooting: number of rows in a resultset

  1. number of rows in a resultset (3 messages)

    can any one giuve solution of how to identify the number of records a result set obejct is having
    for ex

    select * from employees fetches all the records into a result set object i want to find the number of records or number of rows this result set is having any particular method to know the row size

    Threaded Messages (3)

  2. number of rows in a resultset[ Go to top ]

    One option is:
    int numOfRows = rs.getRow();

    I don't have the API in front of me - there may be a direct method for this, but I don't remember any.
    Note that if all you need is the count, it may be faster to select the count directly in SQL.

  3. number of rows in a resultset[ Go to top ]

    Using "SELECT *, Count(pk) FROM Employees" may be faster in terms of brute processing performance but the extra data transmitted along the wire (the count data is added to every row) may slow overall performance.

    The alternative is to make two queries, one to get the count and th other the data itself, but this is probably worse for obvious reasons.

    Depends where the load on the system lies, I guess, but I would be tempted to handle the count in the App Server, using the aforementioned technique:

      int numOfRows = rs.getRow();
  4. number of rows in a resultset[ Go to top ]

    int numOfRows =rs.getRow();

    it worked only if i set the cursor in con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY)
    other wise i get an error that Result Set is mapped to TYPE_FORWARD_ONLY

    i dont want to set the cursor since it reduces the performance so any other solution to overcome this scenario