JDBC Select batching/fetch-size with MySQL

后端 未结 1 1695
执笔经年
执笔经年 2020-12-11 21:14

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

1条回答
  •  天涯浪人
    2020-12-11 21:51

    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)).

    0 讨论(0)
提交回复
热议问题