VOOZH about

URL: https://www.geeksforgeeks.org/java/what-is-rowset-in-java-jdbc/

⇱ RowSet in Java JDBC - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

RowSet in Java JDBC

Last Updated : 6 Apr, 2026

RowSet is an advanced interface in Java provided in the javax.sql package, designed to handle tabular data in a more flexible and user-friendly way than ResultSet. It acts as a wrapper around ResultSet and supports features like scrolling, updating, and easy data manipulation .

  • Unlike ResultSet (in java.sql), RowSet is a JavaBean component with properties and event notification support.
  • Provides better flexibility with features like scrolling, updating, and disconnected operations (in some types).
  • Maintains a connection with the data source .
  • Stores data in tabular form, making it easier to manipulate and use.
👁 resultset
RowSet

Note: RowSet is present in package javax.sql while ResultSet is present in package java.sql.   

RowSets are classified into five categories based on how they are implemented which are listed namely as below:

  • JdbcRowSet
  • CachedRowSet
  • WebRowSet
  • FilteredRowSet
  • JoinRowSet

Declaration of Jdbc RowSet interface

public interface JdbcRowSet extends RowSet, Joinable

In order to connect RowSet with the database, the RowSet interface provides methods for configuring Java bean properties which are depicted below:

void setURL(String url):
void setUserName(String user_name):
void setPassword(String password):

Steps to Create a JdbcRowSet

  1. Create a JdbcRowSet object using RowSetProvider.
  2. Set the database URL using setUrl().
  3. Provide username using setUsername().
  4. Set the password using setPassword().
  5. Define the SQL query using setCommand()

JdbcRowSet rowSet = RowSetProvider.newFactory().createJdbcRowSet();
// 1. Oracle database considered -> rowSet.setUrl("jdbc:oracle:thin:@localhost:1521:xe");
// 2. username is set customly as - root ->rowSet.setUsername("root");
// 3. Password is set customly as ->passrowSet.setPassword("pass");
// 4. Query -> rowSet.setCommand("select * from Students");

Example: Illustrate RowSet in JDBC

Assume we have a table named student in the database as:

+--------------+-------------+

| RollNo | Name | Marks |

+--------------+-------------+

| 1 | jack | 92 |

| 2 | jenny | 90 |

| 3 | mark | 80 |

| 4 | joe | 82 |

+--------------+-------------+

Implementing JdbcRowSet and retrieving the records

Output:

RollNo: 1
Name: jack
Marks: 92
RollNo: 2
Name: jenny
Marks: 90
RollNo: 3
Name: mark
Marks: 80
RollNo: 4
Name: joe
Marks: 82

Comment
Article Tags:
Article Tags: