What are connected and disconnected Row Sets in JDBC?

JDBCJava 8ProgrammingObject Oriented Programming

A RowSet is a wrapper around a ResultSet Object. It can be connected, disconnected from the database and can be serialized. It maintains a JavaBean component by setting the properties. You can pass a RowSet object over the network. By default, the RowSet object is scrollable and updatable.

A RowSet Object is of two types

Connected Row Sets: A connected RowSet object connects to the database using a JDBC driver. It establishes a connection with the database and, carries out the required operations. The connection is maintained until the RowSet object is closed.

Disconnected Row Sets: A disconnected RowSet object connects to the database only while reading from the database and while writing to it. A disconnected RowSet object does not hold a connection with the database/data source while processing the data and thus it operates independently.

A disconnected RowSet object is almost the same as connected RowSet object except they are:

  • Lighter in weight compared to connected RowSet objects.

  • Serializable.

  • Able to send data to light weight clients such as mobiles etc.

JDBC provides four classes that represent disconnected RowSet objects.

  • CachedRowSet: The CachedRowSet is the base implementation of disconnected row sets. It connects to the data source, reads data from it, disconnects with the data source and the processes the retrieved data, reconnects to the data source and writes the modifications.

  • WebRowSet: A WebRowSet extends the CachedRowSet.

  • JoinRowSet: This is able to send data to lightweight clients such as mobiles etc.

  • FilteredRowSet: This enables you to cut down the number of rows that are visible in a RowSet.

Updated on 30-Jul-2019 22:30:25