- TYPE_FORWARD_ONLY : The ResultSet can only be scrolled or navigated in forward direction. This is the default type and is not sensitive to the underlying data store changes.
- TYPE_SCROLL_INSESITIVE: The ResultSet can be scrolled either in forward or backward direction. We can move to absolute location or relative record position using this type of scrolling. However Result set is insensitive or insulated from the underlying data store changes
- TYPE_SCROLL_SENSITIVE: This type is exactly has the same functionality as the TYPE_SCROLL_INSESITIVE in terms of scrolling however the result set is sensitive to the changes in underlying data store.
- CONCUR_READ_ONLY : The ResultSet type object cannot be used for updates to data store.
- CONCUR_UPDATABLE: The ResultSet typeobject can be used for updating the data store.
- HOLD_CURSORS_OVER_COMMIT : ResultSet's are not closed on an commit. Instead they are held. These type is very useful if the ResultSet are read only.
- CLOSE_CURSORS_AT_COMMIT: ResultSet closed immediately on a commit call. This can produce better performance over the later one.
Applying the Above in Coding:
ResultSet can be created by below methods:
1) Using ExecuteQuery() on a Statement type object calling a SELECT query.
2) The second approach is to get a Statement type object from the Connection object using createStatement() method. After a statement is created we can issue getResultSet() call to get the corresponding ResultSet type object.
Boolean bVal=st.execute("SELECT * FROM EMP");
The Connection type object provides 3 overloaded createStatement() methods:
1) Statement createStatement() : This returns a default Statement type object which produces the default ResultSet on calling an executeQuery. The returned ResultSet is ForwardOnly,ReadOnly and cannot hold the result type on transaction commit(). The example [Example1] provided above demonstrates this.
2) Statement createStatement(int resultSetType, int resultSetConcurrency)This
provides flexibility over the plain createStatement() in a way that we can define the ResultType we want after execution of the query.
Example 2: If we want a scrollable ,sensitive,updatable ResultSet we can call as below:
Please note that we can do the same for a PrepareStatement or CallableStatement using prepareStatement() or prepareCall() respectively.
3) Statement createStatement((int resultSetType, int resultSetConcurrency, int resultSetHoldability)
This provides flexibility for even mentioning whether ResultSet is Holdable or not after a commit.