本文介绍了Spring-从查询中获取ResultsSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Spring JDBCTemplate,但是我想收到一个ResultSet,它没有将完整的查询结果存储在内存中,因为您会发现使用Java JDBC执行标准语句.我发现与ResultSet最接近的是

I would like to use Spring JDBCTemplate but I would like to receive a ResultSet, which is not storing full query result in memory, as you would find executing standard statement with java JDBC. The closest I found to the ResultSet was

SqlRowSet sqlRowSet = template.getJdbcOperations().queryForRowSet(query, queryParameters);

但这会将整个数据库结果加载到内存中吗?

but this loads the whole DB result into memory?

推荐答案

如果要使用JDBCTemplate获取ResultSet对象,则可以使用以下代码检索javax.sql.Connection:

If you want to get a ResultSet object with JDBCTemplate you can retrieve the javax.sql.Connection with the following code:

Connection conn = jdbcTemplate.getDataSource().getConnection();

现在您可以执行createStatement()或prepareStatement()来获取ResultSet对象.那是我想到的唯一方法.希望对您有帮助.

And you can now perform a createStatement() or preparedStatement() to get the ResultSet object.That's the only way it comes to my mind. I hope this will help you.

这篇关于Spring-从查询中获取ResultsSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 01:30