Types of ResultSets in JDBC:
- TYPE_FORWARD_ONLY
- A cursor that can only be used to process from the beginning of a ResultSet to the end of it. This is the default type.
- TYPE_SCROLL_INSENSITIVE
- A cursor that can be used to scroll in various ways through a ResultSet. This type of cursor is insensitive to changes made to the database while it is open. It contains rows that satisfy the query when the query was processed or when data is fetched.
- TYPE_SCROLL_SENSITIVE
- A cursor that can be used to scroll in various ways through a ResultSet. This type of cursor is sensitive to changes made to the database while it is open. Changes to the database have a direct impact on the ResultSet data.
Note: The blocking enabled and block size connection properties affect the degree of sensitivity of a TYPE_SCROLL_SENSITIVE cursor. Blocking enhances performance by caching data in the JDBC driver layer itself.
See Example: Sensitive and insensitive ResultSets that shows the difference between sensitive and insensitive ResultSets when rows are inserted into a table.
ConcurrencyConcurrency determines whether the ResultSet can be updated. The types are again defined by constants in the ResultSet interface. The available concurrency settings are as follows:
- CONCUR_READ_ONLY
- A ResultSet that can only be used for reading data out of the database. This is the default setting.
- CONCUR_UPDATEABLE
- A ResultSet that allows you to make changes to it. These changes can be placed into the underlying database. See Change ResultSets for more information.
Posted in: