Setting fetch size to negative number

纵然是瞬间 提交于 2020-01-05 09:22:32

问题


I'm working with someone else's code, which contains the lines:

Connection conn = dataSource.getConnection();
conn.setAutoCommit(false);

Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
stmt.setFetchSize(Integer.MIN_VALUE);

ResultSet rs = stmt.executeQuery(myQuery);

I was wondering if someone could explain the effect of setting the fetch size to Integer.MIN_VALUE? That is, does it fetch the maximum number of rows possible to memory, or does it behave otherwise?

I should mention that our data source is a C3P0 connection pool, which uses the MySQL JDBC driver.


回答1:


From the docs (which explicitly show the two createStatement/setFetchSize lines in an example code snippet):

The combination of a forward-only, read-only result set, with a fetch size of Integer.MIN_VALUE serves as a signal to the driver to stream result sets row-by-row.

In the spirit of teaching to fish, my google search was "mysql fetch size jdbc".



来源:https://stackoverflow.com/questions/24704882/setting-fetch-size-to-negative-number

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!