问题描述
我正在调查使用 javax.sql.rowset.CachedRowSet
在我的应用程序的一部分中,但是我只能找到有关使用专有 sun 实现的信息 com.sun.rowset.CachedRowSetImpl
或 Oracle 特定实现.
I am investigating using javax.sql.rowset.CachedRowSet
in part of my application, however I can only find information on using the proprietary sun implementation com.sun.rowset.CachedRowSetImpl
or Oracle specific implementations.
sun 实现不受支持且可能会发生变化.如果我以后想部署到非 Sun 虚拟机,使用它也可能会导致问题,最后它会在我们的构建日志中留下不可抑制的警告,这些警告可能会掩盖其他警告.
The sun implementation is unsupported and subject to change. Using this could also cause problems if I want to deploy to non-Sun virtual machines in the future, and finally it leaves unsuppressible warnings in our build logs which can mask other warnings.
是否有一个开源替代实现可以让我们与我的应用程序一起部署,并且可以在多个数据库中正常运行?至少支持 MySQL 的东西.
Is there an open source alternative implementation that we I can deploy with my application that will work well across multiple databases? At a minimum something that supports MySQL.
推荐答案
你不应该直接实例化 CachedRowSet 的实现——使用它的 Provider 来获取一个实例:见 http://docs.oracle.com/javase/7/docs/api/javax/sql/rowset/RowSetProvider.html(自 JDK7 起可用)
You shouldn't be directly instantiating implementation of CachedRowSet -- use its Provider to obtain an instance: see http://docs.oracle.com/javase/7/docs/api/javax/sql/rowset/RowSetProvider.html (available since JDK7)
实际上,CachedRowSet 的接口和相关工厂是标准的/可移植的.
In fact, CachedRowSet's interface and related factory are standard/portable.
像下面这样的东西应该可以解决问题:
Something like the following shoud do the trick:
CachedRowSet crs = RowSetProvider.newFactory().createCachedRowSet();
crs.populate(myResultSet);
这篇关于除了专有的 Sun 实现之外,还有其他好的 CachedRowSet 实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!