Nearby lessons
22 of 37JDBC - RowSets
📌 What You Will Learn
- What metadata means and the three metadata types in JDBC
- DatabaseMetaData — information about the database
- ResultSetMetaData — information about query results
- The ResultSet types: forward-only, scrollable, updatable
- What RowSets are and how they improve on ResultSet
RowSets is a fundamental part of database programming with JDBC. This lesson explains RowSets — A Better ResultSet and Program: JdbcRowSet (connected, scrollable) with complete, runnable code examples, clear step-by-step explanations, and common mistakes to avoid with exam-style MCQs at the end.
RowSets — A Better ResultSet
A RowSet is a more flexible, powerful ResultSet. It can be disconnected from the database (works offline), supports scrolling and updating, and can even be sent over a network.
In simple words: A RowSet is a smarter ResultSet that can keep its data even after the connection closes. It works offline, scrolls freely, and can even be sent over a network.
| Point | ResultSet | RowSet |
|---|---|---|
| Connected to DB? | Always connected | Can be disconnected (works offline) |
| Scrollable? | Depends on the type | Always scrollable (JdbcRowSet) |
| Can be serialized over a network? | No | Yes |
| Used for | Basic query results | Advanced, offline, web-friendly data |
Program: JdbcRowSet (connected, scrollable)
Trainer's Note: The javax.sql.rowset package has several RowSet types: JdbcRowSet (connected), CachedRowSet (disconnected, the most used), WebRowSet, JoinRowSet, and FilteredRowSet. For beginners, remember: RowSet = ResultSet + offline capability + scrollability.
Example02
📝 Key Takeaways
- Metadata = data about data; JDBC has three kinds (Database, ResultSet, Parameter).
- DatabaseMetaData (con.getMetaData()) describes the database and its tables.
- ResultSetMetaData (rs.getMetaData()) describes the columns of a result.
- ResultSet types: FORWARD_ONLY, SCROLL_INSENSITIVE, SCROLL_SENSITIVE.
- Concurrency: READ_ONLY or UPDATABLE.
- RowSets are flexible, scrollable, and can work disconnected from the database.
🧠 Test Your Knowledge
4 QuestionsProgress: 0 / 4