This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Originally posted by Masoud Kalali: there are several ways , one is to use setFetchsize(), by this way you set the fetch size explicity
setFetchSize does NOT affect the number of rows in the ResultSet; it affects the number of rows that are buffered by the driver. It's a performance optimization setting, not a logical operation. Some drivers default their fetch size to "all rows" and will run the JVM out of memory with a very large ResultSet, some drivers have a default fetch size of 1 and therefore spend too much time waiting on network transfers of data, some drivers have a default fetch size that is larger but may not be optimal for any particular situation (the Oracle driver has default fetch size of 10 and people usually get better performance with a higher value for the fetch size).