- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
database cursor定义与 JDBC ResultSet API 惊人地相似。
数据库游标可以像ResultSet.TYPE_FORWARD_ONLY一样是只进的.
数据库游标可以滚动,甚至可以像ResultSet.TYPE_SCROLL_SENSITIVE一样设置敏感度。 .
还支持像 ResultSet.HOLD_CURSORS_OVER_COMMIT 这样的可持有性
甚至对位置更新/删除的支持也被复制到 JDBC 中 ResultSet.CONCUR_UPDATABLE
但尽管所有这些相似,MySQL doesn't support database cursors :
MySQL does not support SQL cursors, and the JDBC driver doesn't emulate them, so setCursorName() has no effect.
那么,JDBC 实现是否是一种模仿数据库游标实现的数据访问规范,即使数据库并不真正支持这样的功能?
最佳答案
名字里有什么...
的确,ResultSet
和数据库游标在语义上是相似的。 The SQL:2011 standard指定:
A cursor is a mechanism by which the rows of a table may be acted on (e.g., returned to a host programming language) one at a time.
这听起来很像 ResultSet
。再往下,SQL:2011 标准继续提到:
A cursor declaration descriptor and a result set descriptor have four properties: the sensitivity property (either SENSITIVE, INSENSITIVE, or ASENSITIVE), the scrollability property (either SCROLL or NO SCROLL), the holdability property (either WITH HOLD or WITHOUT HOLD), and the returnability property (either WITH RETURN or WITHOUT RETURN).
换句话说,这些功能都不是 JDBC(或 ODBC)规范团队“发明”的。它们确实以这种形式存在于许多 SQL 数据库实现中,并且与任何规范一样,上述许多功能在 SQL 实现中也是可选的。
您已经在 Jess 之前获得了关于 MySQL 部分的权威响应。 .我想补充一点,JDBC 与任何高级规范一样,有必需的部分和可选的部分。
查看 JDBC Spec ,我可以看到以下相关部分。
6.3 JDBC 4.2 API Compliance
A driver that is compliant with the JDBC specification must do the following:
[...]
It must implement the Statement interface with the exception of the following optional methods:
- [...]
- setCursorName
- [...]
It must implement the ResultSet interface with the exception of the following optional methods:
- [...]
- getCursorName
- [...]
ResultSet
类型的实现也是如此。在规范的更下方,您会发现:
The method
DatabaseMetaData.supportsResultSetType
returnstrue
if the specified type is supported by the driver andfalse
otherwise.
关于java - JDBC ResultSet是应用级查询游标吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32644665/
在我的应用程序中,我必须获取记录并将它们放入二维数组中。我必须首先触发两个查询以找出计数,以便我可以初始化数组,其次是获取数据。它会导致性能下降。我需要提高性能的解决方案。 谢谢。 最佳答案 I ha
在 Zend Framework 应用程序中,它的构建与 ZF2 Getting Started tutorial 中的相册应用程序非常相似,我使用 ResultSet 对象将数据从模型通过 Cont
我是 java 和 SQL 新手,我重复了一个我不知道如何避免的问题: 假设我想创建两个executeQuery,一个在另一个内部,在getRequestsFromDB方法中我创建第一个execute
这个问题已经有答案了: Why should I call close() on a ResultSet and Connection instance? (4 个回答) 已关闭 7 年前。 使用完结
public List searchCourse(String name) { List list = null; Course course = null;
我正在使用两个不同的查询从两个表中选择数据。我正在使用一个连接和一个结果集。两个表都已填充,但第二个查询的 resultset.next() 返回 false,尽管它必须为 true。 我还尝试使用两
试图了解这里发生了什么。 DatabaseMetaData 返回一个空结果集,而实际上相同的 SQL 查询则不会。这不是主要问题,因为我使用第二个代码示例作为解决方法。 DatabaseMetaDat
假设我有多个结果集(每个结果集将引用数据库中的 1 行)(它们属于同一个表。)。现在我想创建合并的结果集,它将实习生拥有所有其他结果集。所以我的主要目标是创建一个组合的 ResultSet,它将指向以
我正在尝试将 influxdb 与我的应用程序集成并处理输出。我正在导入 InfluxDBClient 包以连接到在我的本地计算机上运行的 influx 实例。使用以“influxdb.results
我正在尝试创建一个框架来显示数据库中的所有电影名称,然后他们选择框架中的一行来执行另一个查询。 我有一个 ResultSet (rs),它接收查询执行的结果以选择电影名称。之后,我使用 SQLTabl
我有一个 Servlet,它使用返回 ResultSet 的静态实用程序方法。 在我的 Servlet 代码中,我有 ResultSet rs = SimpleSearch.searchByName(
在从 Postgres 或 Oracle 检索时间戳时(我们称之为 startDate),使用 resultSet.getString("startDate") 调用或 resultSet.getTi
全部, 对于名为Analyze 的类及其构造函数Analyze,该构造函数将Java JDBC Resultset 对象作为参数。 private Resultset analysisSet publ
m 尝试遍历 3 个结果集并比较它们的值。 bt 它抛出这个异常......有人可以帮助我了解我正在经历的地方吗?这是一段代码: java.lang.Object[] reconciledPaymen
我已经尝试使用谷歌搜索并在 SO 上查看了这些线程: java jdbc accessing multiple resultsets Open two resultsets simultaneousl
我在 SQLite 的 JDBC 驱动程序中遇到问题。 我正在使用 SELECT 语句执行查询。 如果我得到一个空的 ResultSet(0 行),那么我会在调用 getString(1) 时看到抛出
我正在尝试根据特定条件搜索表格。在 SQL Developer 中执行时,SQL 查询返回正确的结果(1 行)。在 JDBC 中,resultset 不为 null,但 resultset.next(
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
我正在尝试在 Java 应用程序中处理大量数据。数据存储在 MySQL 数据库中,我使用的是 jdbc 连接器 8.0.11。 我的问题是我需要多次访问每条记录并且再次执行查询需要太多时间。使用 Re
这个问题已经有答案了: Getting java.sql.SQLException: Operation not allowed after ResultSet closed (2 个回答) 已关闭
我是一名优秀的程序员,十分优秀!