Whats in this post?
- Background and Explanation of the code
To copy code: Click “View Source” on the right of this code snippet.
Background and Explanation of the code
This program connects to MySQL database using Type-4 JDBC driver. To get and configure database driver, follow the instructions provided on following post:
In this program we are using scrollable
ResultSetto retrieve data from database. A default
ResultSetobject has a cursor that moves forward only. You also can not set cursor on a particular position directly to fetch required data. Following syntax in the program makes the
ResultSetscrollable and read only:
statement = connection.createStatement(
To compile the program: javac ScrollableResultsetDemo.java
To run the program: java ScrollableResultsetDemo
The attached output displays records from table in both direction, forward and backward.