top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of setFetchSize() and setMaxRows() statement in java?

0 votes
482 views
What is the use of setFetchSize() and setMaxRows() statement in java?
posted Jan 21, 2018 by Frank Lee

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

setFetchSize() defines the number of rows that will be read from the database when the ResultSet needs more rows. The method in the java.sql.Statement interface will set the 'default' value for all the ResultSet derived from that Statement; the method in the java.sql.ResultSet interface will override that value for a specific ResultSet. Since database fetches can be expensive in a networked environment, fetch size has an impact on performance.

setMaxRows() sets the limit of the maximum nuber of rows in a ResultSet object. If this limit is exceeded, the excess rows are "silently dropped". That's all the API says, so the setMaxRows method may not help performance at all other than to decrease memory usage. A value of 0 (default) means no limit.

answer Feb 5, 2018 by Ammy Jack
...