问题标签 [cachedrowset]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - RowSet、CachedRowSet 等的实现
直到今天,我一直ResultSet
在处理查询结果。但今天我读了一点RowSet
,CachedRowset
我意识到它们可以更好地服务于我的目的。虽然在所有示例中我都阅读了 whereRowSet
并被CachedRowSet
称为对象,但当我自己在代码中尝试时,我意识到这些是接口,并且在示例中它们使用了这些接口的一些实现。
现在我的问题是我在哪里可以找到这些实现,有什么官方的吗?
我需要下载它们还是它们随 JDK 一起提供?
java - OracleCachedRowSet 更新内存中的数据而不写入数据库
我正在使用 oracle jdbc cachedrowset 实现来选择从查询返回的几行。然后我使用 cachedrowset.updateInt() 或其他更新方法更新一些数据。我首先使用 cachedrowset.beforeFirst() 取回光标,然后再次遍历行集以打印数据。
问题是我再次使用 getInt() 获得的数据是原始数据。我想获得被原始数据替换的数据。我不打算对 db 进行更改。
我想我可以使用 Rowset 对象作为数据包装器而不更改数据库上的任何数据,仅用于数据操作和查看。有什么办法可以让我得到更新的日期而不是原来的日期?我不想编写自己的数据包装器对象
编辑:这是我获取数据的方式,下面是我更新它的方式
更新代码:
java - CachedRowSet、ResultSetDynaClass 还是其他集合?
我正在清理一个做得很糟糕的大型网络应用程序。我不能一次全部完成,所以我把它分成几部分。我想做的一件事是用函数实现一个类,该函数接受 SQL 语句,然后返回一个集合。我的计划是,一旦解决了问题,我就可以到处寻找一个数据库框架来替换该层,而不会干扰 web 应用程序的其余部分。
从模板样式数据库访问函数中返回 ResultSet 的一个大问题是我无法在不禁用 ResultSet 的情况下关闭连接。
我很高兴在这个旧的stackoverflow 帖子中找到建议。
我阅读了CachedRowSet上引用的文章,但我担心文章在哪里声明它的使用可能会通过将大量结果填充到自身中而产生吸收大量 JVM 内存的问题。
替代的 Apache ResultSetDynaClass或任何其他 Collection 不会有同样的问题吗?结果必须以一种或另一种方式写入内存。正确的?
如果我使用 ChaedRowSet、ResultSetDynaClass 或 Java 集合来存储 ResultSet 数据,我会在关闭 ResultSet 后丢失这些数据吗?
我使用 HashMaps 来存储来自通用数据库查询函数的单个记录。
我怎样才能使用 java Collections 来存储多个记录而不使代码变得繁琐?假设我可以,它会比其他两个选项更节省资源或更灵活吗?
提前感谢您提供任何信息或想法。
java - CachedRowSet:还能用来保存ResultSet数据吗?
我想编写一个 java 函数,它接受一个 SQL 查询并返回一个 ResultSet 以便在其他地方处理。这是无法完成的,因为一旦连接关闭,ResultSet 就会失效。
谷歌搜索,我发现了一篇非常古老(2004 年)的 OReilly 文章,其中有一些看起来像治愈方法的东西:CachedRowSet。您只需放入 ResultSet,CachedRowSet 保存数据,让您关闭连接并使用返回的 CachedRowSet 在别处播放数据。
这篇文章引用了 Sun 的 CachedRowSet 实现,但似乎无处可寻。
现代 javadocs(用于 Java 1.5 及更高版本)似乎有同名的东西,“CachedRowSet”,它不仅仅是 ResultSet 数据的持有者。“CachedRowSet”似乎完成了从获取连接和其他所有事情的整个数据库处理。
那个“CachedRowSet”和旧文章中讨论的一样吗?
我想要一些简单的东西,就像在旧文章中一样。在连接关闭后将 ResultSet 放入以进行处理的东西。
有这样的动物吗?
谢谢
java - 使用 CachedRowSet 插入行失败
我正在使用 CachedRowSetImpl,我可以从数据库中获取数据,但我无法插入。
这是代码:
它抛出异常:
线程“主”java.sql.SQLException 中的异常:在 NewClass.main(NewClass.java:32) 的 com.sun.rowset.CachedRowSetImpl.insertRow(CachedRowSetImpl.java:5462) 插入行失败
我试过 JdbcRowSetImpl 而不是 CachedRowSetImpl ,它工作正常
更新:我使用此代码来捕获有关异常的更多详细信息:
输出是:
SQL 状态:空
错误代码:0
消息:插入行失败
java - 即使 CachedRowSet 超出范围,我是否应该始终关闭它?
考虑以下代码片段:
这里CachedRowSet
对象在方法中本地使用。我需要在这里手动关闭它还是方法完成时它所保存的内容将被自动抓取?
java - 不能在 FilterRowSet 上使用指针?
我正在尝试使用 FilterRowSet 从数据库查询中过滤适当的值。这是我的代码:
问题是在设置过滤条件后无法设置行集的指针,这使得以后无法解析它(或类似的东西)。
在使用 FilteredRowSet 类时,这是一个错误还是我不知道的东西?
java - 使用 Java JBDC CacheRowSet 在多个表上保存数据?
正如上面的问题。我可以使用 JOIN 查询语句在 CachedRowSet 上一次将数据保存到多个表吗?
示例 sql 查询语句如下
SELECT * FROM student INNER JOIN class ON student.class_id = class.id
是否有可能或者我应该使用 JoinRowSet 或其他东西?任何帮助,将不胜感激。先感谢您。
java - Caching ResultSet
Its more like subjective question, The main objective of the question is to Cache java.sql.ResultSet. But I know it is not preferred mechanism as it is tightly coupled with Connection, and data may get flushed when the connection is closed. To address this issue, I am using CachedRowSet. The instance of CachedRowSet will be cached using third party caching tool, which will help me to reduce db calls.
Code snippet of my implementation is given below. The method executeQuery(String)
is implemented in an abstract class, which all sub classes would use to execute the query. There could be customer subclasses as well using this method to fetch data from our system.
Now, I am bit confused with below points
Instead of ResultSet interface, I will return instance of CachedResultSet. Would be that correct replacement for resultSet. Driver JAR,DB classes can be varying across customer environment. Customer would write custom classes and expecting a resultSet from Abstract class. Would that cause any issue? Some thing like below
public class CustomerXX extends BaseClass {
}
Risk involved in this kind of operation( Caching
CachedRowSet
, data correctness)Performance of creating
CachedRowSet
Compatibility with all
ResultSet
operations (ResultSet.getString()
, ResultSet.get..()). If at all Driver expect/produces different subclass ofResultSet
( SayjdbcResultSet
,BaseResultSet
, etc)
I have similar kind of many other question is my mind, I am just writing few of them that I feel valid and has higher priority.
Not sure my question is so vague, does have enough clarity of my requirements.
Any ideas, thoughts, suggestions are highly appreciated, and many thanks in advance
java - 使用 Oracle 日期字段中的 cachedrowset 时如何获取整个日期和时间数据
我从 oracle 获取带有结果集的数据,然后将它们填充到cachedrowset
. 但是当我在数据库中获取一个日期字段并打印它时,它只打印日期。我检查了api并且知道getDate()
方法返回java.sql.date
,并且时间sql.date
被强制转换为0。我测试如果我调用resultset.getString("datefield")
它可以获取完整的日期和时间数据,那么有没有办法使用获取完整的日期和时间数据cahcedrowset
,谢谢
这是我的源代码
执行查询方法
我用了三种方法打印日志
日志内容是