我真搞不懂jdbcRowSet,CachedRowSet和WebRowSet是什么。请给我最好的回答。
发布于 2016-09-25 05:25:16
以下是所有这三方面的明确例子。我认为您会清楚地了解这些RowSet接口。
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"));
} CachedRowSet
一种在内存中缓存其数据的断开连接的行集;不适合于非常大的数据集,但它是提供瘦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"));
}
} WebRowSet
一种连接的行集,它在内部使用HTTP协议与提供数据访问的Java对话;用于使瘦web客户端能够检索并可能更新一组更高级的行。
实现
有关这些RowSet接口实现的更多信息,请参见与此相关的问题https://stackoverflow.com/q/8217493/642706。
https://stackoverflow.com/questions/39683654
复制相似问题