[英]How setMaxRows of jdbcTemplate works
I am trying to understand the way ' setMaxRows
' method of JdbcTemplate
works. 我试图了解
JdbcTemplate
' setMaxRows
'方法的工作方式。 Suppose I have a database table named ' employee
' which has 10 records. 假设我有一个名为“
employee
”的数据库表,其中有10条记录。
I set maxRows to 5 using JdbcTemplate.setMaxRows(5)
. 我使用
JdbcTemplate.setMaxRows(5)
将maxRows设置为5。
Now I do a select using following statement, 现在,我使用以下语句进行选择,
jdbcTemplate.queryForRowSet("select * from employee");
Above statement rightly returns 5 records, but when I have a look at the database logs the query executed there is " select * from employee
", without any limit clause. 上面的语句正确地返回了5条记录,但是当我查看数据库日志时,执行的查询是“
select * from employee
”,没有任何限制子句。
So after setting maxRows
to 'n' does jdbcTemplate
fecthes all records from ' employee
' table and then returns only 'n' rows. 因此,在将
maxRows
设置为'n'之后, jdbcTemplate
感染' employee
'表中的所有记录,然后仅返回'n'行。 Or it fetches only 'n' records from database? 还是只从数据库中获取n条记录?
How the maximum number of rows is handled depends on the JDBC driver. 如何处理最大行数取决于JDBC驱动程序。 The value of
maxRows
is eventually being set on the created Statement
through the corresponding setMaxRows
method. 最终通过相应的
setMaxRows
方法在创建的Statement
上设置maxRows
的值。 What your driver does with that is up to the driver. 您的驱动程序如何处理取决于驱动程序。
The JdbcTemplate
merely passes it on. JdbcTemplate
仅将其传递。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.