skip to main content
Reference : Designing JDBC applications for performance optimization : Returning data : Retrieving result sets
  

Try DataDirect Drivers Now
Retrieving result sets
Most JDBC drivers cannot implement scrollable cursors because of limited support for scrollable cursors in the database system. Unless you are certain that the database supports using a scrollable result set, rs, for example, do not call rs.last and rs.getRow() methods to find out how many rows the result set contains. For JDBC drivers that emulate scrollable cursors, calling rs.last results in the driver retrieving all results across the network to reach the last row. Instead, you can either count the rows by iterating through the result set or get the number of rows by submitting a query with a Count column in the Select clause.
In general, do not write code that relies on the number of result rows from a query because drivers must fetch all rows in a result set to know how many rows the query will return.