I have a Java application using JDBC that runs once per day on my server and interacts with a MySQL database (v5.5) also running on the same server. The app is querying for
The MySQL Connector/J driver will fetch all rows, unless the fetch size is set to Integer.MIN_VALUE
(in which case it will fetch one row at a time AFAIK). See the MySQL Connector/J JDBC API Implementation Notes under ResultSet
.
If you expect memory usage to become a problem (or when it actually becomes a problem), you could also implement paging using the LIMIT
clause (instead of using setFetchSize(Integer.MIN_VALUE)
).