如果用session来保存resultset纪录好不好

mfkzhou 2002-03-18 10:21:45
我用javabean里的session来保存记录好不好
...全文
79 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
skyyoung 2002-03-19
  • 打赏
  • 举报
回复
Get Disconnected with CachedRowSet
The New J2EE RowSet Implementation Provides Updateable Disconnected ResultSets in your JSPs
By Taylor G. Cowan; Reprinted from JavaWorld
February 2001

In spite of the ever-growing access to wireless and physical networks, it is impossible to guarantee uninterrupted database connectivity at all times. Even when reliable database connections are available, as with any other limited resource, they must be used wisely. Caching the updates will solve the problem, a solution that until recently required developers to design and implement the caching layer themselves.

In this article I will introduce you to a new JDBC 2.0TM-related class that can simplify database access code, reduce JDBC connection usage, and provide scrolling to otherwise unscrollable JDBC 1.0 result sets. The class is available from Sun as an early access release and consists of three implementations of the JDBC RowSet interface, one of which I will present in this article. That class, CachedRowSet, will be used here as the data model for a simple JSP application. You will find that it provides ideal data-caching support for smaller Web applications where Enterprise JavaBeansTM (EJBTM) are overkill.

You could consider the CachedRowSet as a "disconnected" ResultSet. It is an early implementation of the javax.sql.RowSet, and because javax.sql.RowSet extends the java.sql.ResultSet interface, you are probably already familiar with many of its methods. The RowSet interface supports the JDBC API from the JavaBeansTM component model perspective. It provides all the methods and features of a standard JDBC 2.0 ResultSet, but doesn't require the continuous use of a database connection. Just like any other JavaBean, implementations of javax.sql.RowSet may be serialized. This allows for ResultSets to be serialized, sent to remote clients, updated, and then sent back to the server.

The release of the CachedRowSet is timely, since many Web developers are now familiar with updateable result sets such as Microsoft's ActiveX Data Objects (ADO). Many entry/update forms require the ability to scroll backward and forward through a set of records. Ideally the user will perform updates to the records in their cached state and then apply all the changes at once using a Save command. Though the JDBC 2.0 ResultSet interface supports this type of scrolling, because it requires each session to maintain an open connection to the database while the user browses through records, you probably would not want to use it. To maximize database resources, you should utilize a connection only when absolutely necessary. When a connection is not required, you should release it into the connection pool as soon as possible. The CachedRowSet offers this flexibility; it only needs a connection while it performs a query or update.

I fully expect that third-party implementations of javax.sql.RowSet will appear shortly, but in the meantime, the CachedRowSet is available to developers who want to familiarize themselves with the new Java 2 Platform, Enterprise Edition (J2EETM) javax.sql.RowSet interface.

Currently you can download the CachedRowSet implementation from the Java Developer Connection as an early access release. After downloading and unzipping the installation files, add the file "rowset.jar" to your classpath. The CachedRowSet object is located in package sun.jdbc.rowset.

............
skyyoung 2002-03-19
  • 打赏
  • 举报
回复
resultset不可以序列化,所以不可以保存在Session里。
想保存的话,用http://developer.java.sun.com/developer/technicalArticles/javaserverpages/cachedrowset/
lbluekey 2002-03-19
  • 打赏
  • 举报
回复
这个可以看你的具体情况,如果是一些数据字典,数据量不大,可以放在
javabean里边,但这种通常是applocation而较少使用 session的,因为他们是公用的!
至于特定的用户数据,如果是临时的数据,或中间数据,可以放在 session中,否则最好不要这样
ctrlpower 2002-03-19
  • 打赏
  • 举报
回复
我认为不太恰当!
一旦访问量一大,服务器受不了!
你可以把resultset 放到 vector 里面,然后从vector里面找到你需要的数据!

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧