Mer
Mer

Reputation: 762

Serializable snapshot of JDBCRowSet?

JdbcRowSet interface is a connected RowSet, and, unlike CachedRowSet, does not implement Serializable.
What would happen if you created a class which implemented both JdbcRowSet and Serializable? Would it effectively send a snapshot of the JdbcRowSet at the time of serialization, or would such a class be impossible to put to any use?

(This is more for my own understanding than for any application; I understand that a CachedRowSet implementation is probably the correct route to go to achieve the same result.)

Upvotes: 0

Views: 522

Answers (1)

Sagar Joon
Sagar Joon

Reputation: 1417

Since JDBCRowSet is a connected architecture ,it is not desirable to make the class serialized because it maintains the connection to the database with the help of jdbc drivers.So, its Better to go with CachedRowSet (in case of serialization) which in turn is a disconnected architecture.

Here is the difference between these two kinds of RowSet : 1) JdbcRowSet: The JdbcRowSet class provides a basic implementation of the javax.sql.RowSet interface, which turns a ResultSet object into a JavaBean and abstracts the details of working with ResultSet objects. You can use this object to simplify connection steps or to provide scrollable and updateable cursors for drivers that do not support these features. However, JdbcRowSet objects can only operate in connected mode, thus requiring the presence of a JDBC driver.

2) Cached RowSet: The CachedRowSet class provides the same functionality as the JdbcRowSet class, with one important difference: a CachedRowSet object can operate in a disconnected environment. As a result, it can function without a JDBC driver present. Once you populate a CachedRowSet object with data you may send it over the network to thin clients, provide it to sales professionals on their laptops, or serialize it for data archiving. The advantage of the CachedRowSet object is that the client to whom you send the object does not need the JDBC driver.

Upvotes: 0

Related Questions