gpt4 book ai didi

java - 如何在游标上设置FetchSize

转载 作者:太空宇宙 更新时间:2023-11-04 14:25:01 28 4
gpt4 key购买 nike

如何设置存储过程返回的游标的获取大小。请找到我的以下代码片段:

conn.setAutoCommit(false);
cstmt = (CallableStatement) conn.createStatement();
cstmt = conn.prepareCall(sqlQuery);
cstmt.execute();
rst = (ResultSet) cstmt.getObject(sqlQuery);
rst.setFetchSize(100);

但是结果集似乎忽略了setFetchSize。有人可以建议我解决方案吗?另外我的oracle版本是ojdbc11.2.0

最佳答案

您需要将autocommit设置为false,

conObj.setAutoCommit(false);

并加载callable语句,CallableStatement cstmt = connObj.createStatement();

来自文档,

In the case of statements returning a ResultSet, the statement completes when the last row of the ResultSet has been retrieved or when the ResultSet has been closed. In more complex cases, a single statement can return multiple results as well as output parameter values. Here, the COMMIT occurs when all results and output parameter values have been retrieved.

关于java - 如何在游标上设置FetchSize,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26777992/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com