while (rs.next())
{
ret.add(rs.getLong(1));
}
} finally
{
if (stmt != null)
stmt.close();
if (rs != null)
rs.close();
if (conn != null)
dbMgr.releaseConnection(conn);
}
When testing in Oracle, above loop is very slow. If add setFetchSize before next, the performance improve significantly
ResultSet interface also provides batch retrieval facility like Statement as mentioned above. It overrides the Statement behaviour.
Initially find the default size by using
ResultSet.getFetchSize(); and then set the size as per requirement
ResultSet.setFetchSize(50);
This feature significantly improves performance when you are dealing with retrieval of large number of rows like search functionality.
TODO: reading full tips
http://www.precisejava.com/javaperf/j2ee/JDBC.htm#JDBC114