java - 如何在spring jdbc模板中制作流式sql?

标签 java sql spring java-8 jdbctemplate

我们在 spring jdbc 模板中有一个 sql 来获取数百万条记录,我们想用 Java 处理这些记录。有没有办法使用更少的内存来做同样的事情?

最佳答案

您可能对以下内容感兴趣:

JdbcTemplate.setFetchSize(int fetchSize)

从文档:

Set the fetch size for this JdbcTemplate. This is important for processing large result sets: Setting this higher than the default value will increase processing speed at the cost of memory consumption; setting this lower can avoid transferring row data that will never be read by the application.

Default is 0, indicating to use the JDBC driver's default.

关于java - 如何在spring jdbc模板中制作流式sql?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52542824/

相关文章:

java - Spring Boot 未连接到 RabbitMQ

java - 获取自己的 MBean 的所有已注册实例

java - 从 Path 中捕获元素

java - Spring Boot Sql Date Timestamp Json 序列化问题

应用程序启动中的JavaFX简单按钮异常?

java - 使用旧版 JAVA API 进行 regExp 匹配

mysql - 寻找最小距离MYSQL

mysql - 我需要在此 SQL 指令中添加什么来过滤某些项目?

MySQL 查询工作正常,但在 Netbeans 的 Java 代码中实现时出错

java - Spring AOP 表达式抛出 java.lang.IllegalArgumentException : warning no match for this type name [. ..]