Skip to content
Related Articles

Related Articles

Improve Article

Java JDBC – Difference Between Row Set and Result Set

  • Difficulty Level : Medium
  • Last Updated : 31 Jul, 2021
Geek Week

 ResultSet characteristics are as follows:

  • It maintains a connection to a database and because of that, it can’t be serialized.
  • it can not pass the Result set object from one class to another class across the network.
  • ResultSet object maintains a cursor pointing to its current row of data. Initially, the cursor is positioned before the first row. The next method moves the cursor to the next row, and because it returns false when there are no more rows in the ResultSet object, it can be used in a while loop to iterate through the result set.
  • javax.sql.rowset.RowSet is a wrapper around a ResultSet which makes it possible to use the result set as a JavaBeans component in JDBC java.
  • ResultSet alone cannot be used as a JavaBeans component.

RowSet  characteristics are as follows:

  • it is a disconnected, serializable version of a JDBC ResultSet. it also extends the ResultSet interface.
  • The Row Set can be serialized because it doesn’t have a connection to any database.
  • The Row Set interface provides a set of JavaBeans properties that allow a Row Set instance to be configured to connect to a JDBC data source and read some data from the data source. A group of setter methods (setInt, setBytes, setString, and so on) provides a way to pass input parameters to a row set’s command property.
  • Row Set interface extends ResultSet interface in java.
  • javax.sql.rowset.JdbcRowSet the subclass of Row Set is a wrapper around a ResultSet which makes it possible to use the result set as a JavaBeans component.

Note: RowSet is alternate to ResultSet but is more effective than ResultSet

Now let us wrap up differentiating them that is as follows:



          RowSet                                                                                    ResultSet                                              
RowSet is present in the javax.sql package ResultSet is present in the java.sql package 
A Row Set can be connected, disconnected from the database.A ResultSet always maintains the connection with the database.
RowSet is scrollable providing more flexibility  ResultSet by default is always forward only 
 A Row Set object can be serialized.It cannot be serialized.
You can pass a Row Set object over the network.ResultSet object cannot be passed other over the network.

Result Set Object is a JavaBean object.

 RowSet using the RowSetProvider.newFactory().createJdb cRowSet() method.

Result Set object is not a JavaBean object

result set using the executeQuery() method

ResultSetBy default, RowSet object is scrollable and updatable.By default, the ResultSet object is not scrollable or, updatable.

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :