JDBC结果集类型滚动敏感 [英] JDBC result set type scroll sensitive

查看:111
本文介绍了JDBC结果集类型滚动敏感的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ResultSet.TYPE_SCROLL_SENSITIVE在JDBC中实际上如何工作?

How does ResultSet.TYPE_SCROLL_SENSITIVE actually work in JDBC?

Statement stmt = conn.createStatement(
                       ResultSet.TYPE_SCROLL_SENSITIVE,
                       ResultSet.CONCUR_READ_ONLY);`

推荐答案

JDBC规范说:

ResultSet对象的类型确定其功能级别 在两个主要方面:(1)操纵光标的方式 (2)如何对基础数据源进行并发更改 由ResultSet对象反映.后者称为灵敏度 ResultSet对象的

The type of a ResultSet object determines the level of its functionality in two main areas: (1) the ways in which the cursor can be manipulated and (2) how concurrent changes made to the underlying data source are reflected by the ResultSet object. The latter is called the sensitivity of the ResultSet object.

以下描述了三种不同的ResultSet类型.

The three different ResultSet types are described below.

[...]

3. TYPE_SCROLL_SENSITIVE

  • 结果集是可滚动的;它的光标可以向前和向后移动 相对于当前位置向后移动,它可以移动到 绝对位置.
  • 结果集反映对基础数据源所做的更改 结果集保持打开状态.
  • The result set is scrollable; its cursor can move both forward and backward relative to the current position, and it can move to an absolute position.
  • The result set reflects changes made to the underlying data source while the result set remains open.

默认的ResultSet类型为TYPE_FORWARD_ONLY.

方法DatabaseMetaData.supportsResultSetType返回true 如果驱动程序支持指定的类型,否则为false.

The method DatabaseMetaData.supportsResultSetType returns true if the specified type is supported by the driver and false otherwise.

如果驱动程序不支持提供给方法的类型 createStatementprepareStatementprepareCall,它会生成一个 正在创建语句的Connection对象上的SQLWarning. 执行该语句时,驱动程序返回ResultSet对象 最接近所请求类型的类型.一个应用程序 可以通过调用方法找出ResultSet对象的类型 ResultSet.getType.

If the driver does not support the type supplied to the methods createStatement, prepareStatement, or prepareCall, it generates an SQLWarning on the Connection object that is creating the statement. When the statement is executed, the driver returns a ResultSet object of a type that most closely matches the requested type. An application can find out the type of a ResultSet object by calling the method ResultSet.getType.

这篇关于JDBC结果集类型滚动敏感的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆