Getting the Cursor Position in a Scrollable Result Set

try { // Create a scrollable result set Statement stmt = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery("SELECT * FROM my_table"); // Get cursor position int pos = resultSet.getRow(); // 0 boolean b = resultSet.isBeforeFirst(); // true // Move cursor to the first row resultSet.next(); // Get cursor position pos = resultSet.getRow(); // 1 b = resultSet.isFirst(); // true // Move cursor to the last row resultSet.last(); // Get cursor position pos = resultSet.getRow(); // If table has 10 rows, value would be 10 b = resultSet.isLast(); // true // Move cursor past last row resultSet.afterLast(); // Get cursor position pos = resultSet.getRow(); // If table has 10 rows, value would be 11 b = resultSet.isAfterLast(); // true } catch (SQLException e) { }

Comments

3 Sep 2010 - 12:33am by tudor watches (not verified)

It's a two-way street, Nike golf equipment Silverman said. It's not just gucci backpack what the kids learn, it's burberry watches for men what the coaches and the maurice lacroix watches adults and buddies learn. Nike messenger bag

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.