问题描述
我正在使用别人的代码,其中包含以下行:
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);
我想知道是否有人可以解释将获取大小设置为Integer.MIN_VALUE的效果?也就是说,它会获取可能存储的最大行数,还是会表现其他方式?
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?
我应该提到我们的数据源是一个C3P0连接池,它使用MySQL JDBC驱动程序.
I should mention that our data source is a C3P0 connection pool, which uses the MySQL JDBC driver.
推荐答案
来自文档(在示例代码段中明确显示了两个createStatement
/setFetchSize
行):
From the docs (which explicitly show the two createStatement
/setFetchSize
lines in an example code snippet):
本着钓鱼的精神,我的Google搜索是"mysql fetch size jdbc".
In the spirit of teaching to fish, my google search was "mysql fetch size jdbc".
这篇关于将抓取大小设置为负数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!