What are different types of ResultSet?
There are different types of ResultSet objects that we can get based on the user input while creating the Statement. If you will look into the Connection methods, you will see that createStatement() and prepareStatement() method are overloaded to provide ResultSet type and concurrency as input argument.
There are three types of ResultSet object.
- TYPE_FORWARD_ONLY: This is the default type and cursor can only move forward in the result set.
- TYPE_SCROLL_INSENSITIVE: The cursor can move forward and backward, and the result set is not sensitive to changes made by others to the database after the result set was created.
- TYPE_SCROLL_SENSITIVE: The cursor can move forward and backward, and the result set is sensitive to changes made by others to the database after the result set was created.
Based on the concurrency there are two types of ResultSet object.
- CONCUR_READ_ONLY: The result set is read only, this is the default concurrency type.
- CONCUR_UPDATABLE: We can use ResultSet update method to update the rows data.