1

I am so confused What is jdbcRowSet, CachedRowSet and WebRowSet. Please Give Me best Answer.

Ng Sharma
  • 2,072
  • 8
  • 27
  • 49

1 Answers1

1

Refer below for clear examples of all three. I think you will get clear picture about these RowSet interfaces.

JDBCRowSet

A connected rowset that serves mainly as a thin wrapper around a ResultSet object to make a JDBC driver look like a JavaBeans component. 

Example: 

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

A disconnected rowset that caches its data in memory; not suitable for very large data sets, but an ideal way to provide thin Java clients. 

Example : 

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

A connected rowset that uses the HTTP protocol internally to talk to a Java servlet that provides data access;  used to make it possible for thin web clients to retrieve and possibly update a set of rows. 

Implementations

For more info about implementations of these RowSet interfaces, see this related Question, Implementations of RowSet, CachedRowSet etc.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
Vivek Kumar
  • 360
  • 1
  • 7
  • 16
  • Thanks you Vivek kumar. – Ng Sharma Sep 25 '16 at 05:30
  • More info: You will need to find an implementation of these [`RowSet`](http://download.java.net/java/jdk9/docs/api/javax/sql/RowSet.html) interfaces. Sun provided an open-source implementation. You may find others too. Unfortunately, despite their seeming usefulness, much of the database community has ignored these RowSet interfaces, apparently out of ignorance. – Basil Bourque Oct 16 '17 at 05:35