- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我试图了解这两种创建语句的方法之间的区别:
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
第二个参数相同但第一个参数不同
来自 java 文档:
resultSetType
- a result set type; one ofResultSet.TYPE_FORWARD_ONLY
,ResultSet.TYPE_SCROLL_INSENSITIVE
, orResultSet.TYPE_SCROLL_SENSITIVE
和
TYPE_SCROLL_INSENSITIVE
The constant indicating the type for aResultSet
object that is scrollable but generally not sensitive to changes to the data that underlies theResultSet
.
TYPE_SCROLL_SENSITIVE
The constant indicating the type for aResultSet
object that is scrollable and generally sensitive to changes to the data that underlies theResultSet
.
因此,我想展示 ResultSet
底层的敏感性之间的差异。我想了解“对 ResultSet
下的数据变化敏感”(来自 Javadoc)是什么意思。
请提供一个示例来说明和解释差异。
最佳答案
敏感性与基础数据(数据库)有关。
假设您在数据库中有 PEOPLE 表。您创建不敏感的声明:
Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
在时间 8:20 你发出了一个查询
SELECT * FROM PEOPLE;
现在让结果集保持打开状态,然后使用 next()、previous() 和 absolute(int)) 方法滚动浏览它。
8:23 有人更新了 PEOPLE 表中的数据。
在 8:24,您仍在滚动结果集,但因为您有 INSENSITIVE 结果集,所以您看到的是旧数据。
现在不同了。如果您使用 SENSITIVE 创建语句,那么您将看到在 8:23 进行的所有更改。
关于java - 结果集 TYPE_SCROLL_SENSITIVE 和 TYPE_SCROLL_INSENSITIVE 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25585218/
我正在使用 sql server 数据库开发一个 Java 项目,一旦我使用 stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
我正在编写一段简单的代码: import java.sql.*; class ODBC { MyConnection myCon; Connection jdbcConnection; Result
所以 TYPE_SCROLL_INSENSITIVE 结果集允许我在两个方向上滚动,而 TYPE_FORWARD_ONLY 只允许我向前移动。 既然 TYPE_SCROLL_INSENSITIVE 允
JavaDoc 说:“指示 ResultSet 对象类型的常量是可滚动的,但通常对 ResultSet 下的数据的更改不敏感”. 我对可滚动部分很清楚,但对声明的后半部分有疑问。我正在使用以下代码片段
我试图了解这两种创建语句的方法之间的区别: 1: Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSE
在一个项目期间,我们发现我们正在执行的一些 SQL 语句(但不是全部)在 Java 应用程序中返回的结果与在 Aquadata 或 Toad 等独立 SQL IDE 中运行时返回的结果不同。这使用 D
我是一名优秀的程序员,十分优秀!