加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 在Statement与ResultSet上设置提取大小之间的区别

发布时间:2020-12-15 00:54:46 所属栏目:Java 来源:网络整理
导读:在Statement与ResultSet上设置提取大小有什么区别? Oracle文档说如果在Statement上设置了获取大小,那么ResultSet也会使用相同的大小,只要在获取结果集之前设置了获取大小.如果我在Statement或ResultSet上设置它会有什么不同?我正在使用Oracle数据库.以下是
在Statement与ResultSet上设置提取大小有什么区别? Oracle文档说如果在Statement上设置了获取大小,那么ResultSet也会使用相同的大小,只要在获取结果集之前设置了获取大小.如果我在Statement或ResultSet上设置它会有什么不同?我正在使用Oracle数据库.以下是有关它的Oracle文档:

Fetch Size

By default,when Oracle JDBC runs a query,it retrieves a result set of 10 rows at a time from the database cursor. This is the default Oracle row fetch size value. You can change the number of rows retrieved with each trip to the database cursor by changing the row fetch size value.

Standard JDBC also enables you to specify the number of rows fetched with each database round-trip for a query,and this number is referred to as the fetch size. In Oracle JDBC,the row-prefetch value is used as the default fetch size in a statement object. Setting the fetch size overrides the row-prefetch setting and affects subsequent queries run through that statement object.

Fetch size is also used in a result set. When the statement object run a query,the fetch size of the statement object is passed to the result set object produced by the query. However,you can also set the fetch size in the result set object to override the statement fetch size that was passed to it.

解决方法

获取大小真正重要的唯一位置是ResultSet.创建ResultSet时,它会从用于创建它的Statement获取其获取大小,但可以在以后更改.

将Statement的提取大小视为默认值,将其传递给它创建的所有ResultSet.如果您不想使用此默认值,则可以覆盖它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读