How can you retrieve data from the ResultSet?
1. Create a ResultSet containing all data from my_tab
stmt = con.createStatement()
rs = stmt.executeQuery("SELECT * FROM my_tab")
2. Fetch each row from the ResultSet rs.next()
3. Get the data from the row using the column index
rs.getString(1)
4. Get the data from the row using the column name
rs.getString(columnName)
What are the various means of accessing results from ResultSet objects? Explain them.
Scrollable ResultSets
Scroll sensitivity
Updatable ResultSets.
Scrollable ResultsetsScrolling resembles the moving the cursor in a set of rows. The ResultSets are scrollable by nature. The cursor can move through the ResultSet. The scrolling can be made in bidirectional fashion.
Scroll Sensitivity JDBC API allows the cursor in a ResultSet to scrollable and in general sensitive to the modifications. The rows in the ResultSet scroll from the first row and up to the row which has the highest identification / number when the rows are requested. Using the static final member of ResultSet, TYPE_SCROLL_SENSITIVE.
Updatable ResultsetsJDBC API allows the result sets to be updated. To get the data to be updated in the concurrency mode the static final members CONCUR_UPDATABLE is used.
Explain the types of Scrollable Resultsets.
TYPE_FORWARD_ONLY
TYPE_SCROLL_INSENSITIVE
TYPE_SCROLL_SENSITIVE
TYPE_FORWARD_ONLYTo make the cursor to move in the forward direction only in the specified ResultSet this static final member is used.
TYPE_SCROLL_INSENSITIVETo make the cursor to move in the forward direction only and to make not sensitive for the changes which were done by others