TYPE_SCROLL_SENSITIVE to TYPE_SCROLL_INSENSITIVE

简介: TYPE_SCROLL_SENSITIVE to TYPE_SCROLL_INSENSITIVE

相关开发要求和限制 参考:https://docs.oracle.com/database/121/JJDBC/resltset.htm#JJDBC28629:

17 Result Set

Resultset Limitations and Downgrade Rules

ome types of result sets are not feasible for certain kinds of queries. If you specify an unfeasible result set type or concurrency type for the query you run, then the JDBC driver follows a set of rules to determine the best feasible types to use instead.

The actual result set type and concurrency type are determined when the statement is run, with the driver issuing a SQLWarning on the statement object if the desired result set type or concurrency type is not feasible. The SQLWarning object will contain the reason why the requested type was not feasible. Check for warnings to verify whether you received the type of result set that you requested.

Result Set Limitations

The following limitations are placed on queries for enhanced result sets. Failure to follow these guidelines results in the JDBC driver choosing an alternative result set type or concurrency type.

To produce an updatable result set:

A query can select from only a single table and cannot contain any join operations.

In addition, for inserts to be feasible, the query must select all non-nullable columns and all columns that do not have a default value.

A query cannot use SELECT * .

However, there is a workaround for this.

A query must select table columns only.

It cannot select derived columns or aggregates, such as the SUM or MAX of a set of columns.

To produce a scroll-sensitive result set:

A query cannot use SELECT * .

However, there is a workaround for this.

A query can select from only a single table.

Scrollable and updatable result sets cannot have any column as Stream. When the server has to fetch a Stream column, it reduces the fetch size to one and blocks all columns following the Stream column until the Stream column is read. As a result, columns cannot be fetched in bulk and scrolled through.

Workaround

As a workaround for the SELECT * limitation, you can use table aliases, as shown in the following example:

SELECT t.* FROM TABLE t ...
Note:

There is a simple way to determine if your query will probably produce a scroll-sensitive or updatable result set: If you can legally add a ROWID column to the query list, then the query is probably suitable for either a scroll-sensitive or an updatable result set.
Result Set Downgrade Rules

If the specified result set type or concurrency type is not feasible, then Oracle JDBC driver uses the following rules in choosing alternate types:

If the specified result set type is TYPE_SCROLL_SENSITIVE, but the JDBC driver cannot fulfill that request, then the driver attempts a downgrade to TYPE_SCROLL_INSENSITIVE.

If the specified or downgraded result set type is TYPE_SCROLL_INSENSITIVE, but the JDBC driver cannot fulfill that request, then the driver attempts a downgrade to TYPE_FORWARD_ONLY.

If the specified concurrency type is CONCUR_UPDATABLE, but the JDBC driver cannot fulfill that request, then the JDBC driver attempts a downgrade to CONCUR_READ_ONLY.

Note:

Any manipulations of the result set type and concurrency type by the JDBC driver are independent of each other.
Verifying Result Set Type and Concurrency Type

After a query has been run, you can verify the result set type and concurrency type that the JDBC driver actually used, by calling methods on the result set object.

int getType() throws SQLException

This method returns an int value for the result set type used for the query. ResultSet.TYPE_FORWARD_ONLY, ResultSet.TYPE_SCROLL_SENSITIVE, or ResultSet.TYPE_SCROLL_INSENSITIVE are the possible values.

int getConcurrency() throws SQLException

This method returns an int value for the concurrency type used for the query. ResultSet.CONCUR_READ_ONLY or ResultSet.CONCUR_UPDATABLE are the possible values.

Avoiding Update Conflicts
It is important to be aware of the following facts regarding updatable result sets with the JDBC drivers:

The drivers do not enforce write locks for an updatable result set.

The drivers do not check for conflicts with a result set DELETE or UPDATE operation.

A conflict will occur if you try to perform a DELETE or UPDATE operation on a row updated by another committed transaction.

Oracle JDBC drivers use the ROWID to uniquely identify a row in a database table. As long as the ROWID is valid when a driver tries to send an UPDATE or DELETE operation to the database, the operation will be run.

The driver will not report any changes made by another committed transaction. Any conflicts are silently ignored and your changes will overwrite the previous changes.

To avoid such conflicts, use the Oracle FOR UPDATE feature when running the query that produces the result set. This will avoid conflicts, but will also prevent simultaneous access to the data. Only a single write lock can be held concurrently on a data item.

相关文章
|
运维 监控 Cloud Native
|
机器学习/深度学习 算法框架/工具 数据库
使用Python实现深度学习模型:智能城市噪音监测与控制
使用Python实现深度学习模型:智能城市噪音监测与控制
431 1
|
自然语言处理 Serverless API
基于 EventBridge + DashVector 打造 RAG 全链路动态语义检索能力
本文将演示如何使用事件总线(EventBridge),向量检索服务(DashVector),函数计算(FunctionCompute)结合灵积模型服务[1]上的 Embedding API[2],来从 0 到 1 构建基于文本索引的构建+向量检索基础上的语义搜索能力。具体来说,我们将基于 OSS 文本文档动态插入数据,进行实时的文本语义搜索,查询最相似的相关内容。
529 169
|
自动驾驶 物联网 5G
5G网络的演进:从理论到实践
【10月更文挑战第3天】5G网络作为新一代移动通信技术,不仅在理论上实现了重大突破,而且在实践中也展现出了强大的生命力。本文将围绕5G网络的演进,从理论基础到实际应用,探讨5G技术的发展和实践案例,同时提供代码示例以供参考。
605 6
|
12月前
|
人工智能 Serverless API
10 分钟打造你的专属 AI 客服
在这个数字化时代,提供卓越的客户服务已成为企业脱颖而出的关键。为了满足这一需求,越来越多的企业开始探索人工智能(AI)助手的应用,以实现全天候(7x24)的客户咨询响应,全面提升用户体验和业务竞争力。本解决方案通过函数计算FC 和大模型服务平台百炼,为您提供一个高效便捷构建 AI 助手思路。
899 43
|
安全 Java
线程安全的艺术:确保并发程序的正确性
在多线程环境中,确保线程安全是编程中的一个核心挑战。线程安全问题可能导致数据不一致、程序崩溃甚至安全漏洞。本文将分享如何确保线程安全,探讨不同的技术策略和最佳实践。
198 6
|
算法
Modbus-ASCII数据帧
Modbus-ASCII数据帧
232 1
|
存储 Kubernetes API
kubernetes代码阅读-apiserver之list-watch篇
apiserver的list-watch代码解读 list-watch,作为k8s系统中统一的异步消息传递方式,对系统的性能、数据一致性起到关键性的作用。今天我想从代码这边探究一下list-watch的实现方式。
1615 0
|
监控 关系型数据库 MySQL
MySQL性能调优与监控:优化查询与实时监测
本文深入探讨了MySQL数据库的性能调优与监控,通过详细的代码示例,介绍了优化器与执行计划、查询性能调优策略,以及性能监控工具与指标。优化查询性能是数据库管理中的关键环节,通过合理的查询设计、索引的使用和避免不必要的操作,可以显著提升数据库操作效率。性能监控工具如MySQL Performance Schema和MySQL Enterprise Monitor能够实时监测数据库的性能指标,帮助管理员及时发现和解决性能问题。
1609 0
MySQL性能调优与监控:优化查询与实时监测
|
安全 关系型数据库 MySQL
提升PHP安全:8个必须修改的PHP默认配置
提升PHP安全:8个必须修改的PHP默认配置
233 0

热门文章

最新文章