为什么我的spring启动应用程序中jdbcTemplate的默认提取大小为-1?

时间:2017-04-26 19:14:30

标签: spring spring-boot spring-jdbc jdbctemplate

我正在运行spring boot 1.4.3应用程序。我正在使用net.sourceforge.jtds.jdbc.Driver连接到SQL Server数据库。

当我打印出jdbcTemplate和驱动程序的默认提取大小时,我会得到不同的值。

jdbcTemplate fetch size is -1
jtds driverfetch size is 100

这是我从jdbcTemplate获取提取大小的方法

int jtdsFetchSize = template.getDataSource().getConnection().createStatement().getFetchSize();
int jdcTemplateFetchSize = template.getFetchSize();

几个问题

  1. 为什么jdbcTemplate获取大小为-1,而documentation表示默认值为零。

  2. 在上面的例子中,执行语句时的实际提取大小是多少。我在select statments上收到OOM内存错误,我猜测值-1表示获取大小为ALL。但我找不到任何支持它的文档。

  3. Thansk

1 个答案:

答案 0 :(得分:0)

我认为你应该使用Error using cat Dimensions of matrices being concatenated are not consistent. Error in cell2mat (line 78) m = cat(1,m{:}); Error in mpengujianbmpengujianbplay_Callback (line 222) T=cell2mat(data2); 而不是setMaxRows。 在我看来,fetchSize更多的是限制单个记录的大小,而maxRows则限制总记录的大小。 因此,您可以尝试下次使用setFetchSize