gpt4 book ai didi

java - JdbcRowSet、CachedRowSet 和 WebRowSet 的区别

转载 作者:行者123 更新时间:2023-11-28 23:25:11 25 4
gpt4 key购买 nike

我很困惑什么是jdbcRowSet、CachedRowSet和WebRowSet。请给我最佳答案。

最佳答案

请参阅下面的所有三个示例。我想你会清楚地了解这些 RowSet接口(interface)。

JDBCRowSet

一个连接的行集,主要用作 ResultSet 对象的薄包装器,使 JDBC 驱动程序看起来像一个 JavaBeans 组件。

示例:

JdbcRowSet jdbcRs = new JdbcRowSetImpl(); 
jdbcRs.setUsername("scott"); 
jdbcRs.setPassword("tiger"); 
jdbcRs.setUrl("jdbc:oracle://localhost:3306/test"); 
jdbcRs.setCommand("select * from employee"); 
jdbcRs.execute(); 
while(jdbcRs.next()) { 
System.out.println(jdbcRs.getString("emp_name")); 

缓存行集

将其数据缓存在内存中的断开连接的行集;不适合非常大的数据集,但却是提供瘦 Java 客户端的理想方式。

示例:

CachedRowSet cachedRs = new CachedRowSetImpl(); 
cachedRs.setUsername("scott"); 
cachedRs.setPassword("tiger"); 
cachedRs.setUrl("jdbc:oracle://localhost:3306/test"); 
cachedRs.setCommand("select * from employee"); 
cachedRs.setPageSize(4); 
cachedRs.execute(); 
while (cachedRs.nextPage()) { 
while (cachedRs.next()) { 
System.out.println(cachedRs.getString("emp_name"));


网络行集

内部使用 HTTP 协议(protocol)与提供数据访问的 Java servlet 对话的连接行集;用于使瘦 Web 客户端可以检索并可能更新一组行。

实现

有关这些 RowSet 实现的更多信息接口(interface),请参阅此相关问题,Implementations of RowSet, CachedRowSet etc .

关于java - JdbcRowSet、CachedRowSet 和 WebRowSet 的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39683654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com