I was trying to get the size of a JDBC result set without the usage of some gay code like "while(rs.next()) { //increment an index}" or worse, creating another statement with the query "select count(*) .... " to retreive only the number of rows from the targeted table.
Even though at first you might want to try resultSet.getFetchSize() , it will not get the "fetch size" specified in the nomenclature, i.e. the number of rows you seek. A closer peek at the jdbc documentation states that getFetchSize() "Retrieves the number of result set rows that is the default fetch size for result sets generated from this
The solution for this ? there is no predefined method in the Statement metadata to return the result set size without parsing it... you may need to choose one of the (gay) methods specified above or find some other.
Even though at first you might want to try resultSet.getFetchSize() , it will not get the "fetch size" specified in the nomenclature, i.e. the number of rows you seek. A closer peek at the jdbc documentation states that getFetchSize() "Retrieves the number of result set rows that is the default fetch size for result sets generated from this
Statement
object" .The solution for this ? there is no predefined method in the Statement metadata to return the result set size without parsing it... you may need to choose one of the (gay) methods specified above or find some other.
No comments:
Post a Comment