How do I check if cursor is in the last row?

On the previous example we check if the cursor is before the first row in the result set. Now using the isAfterLast() method we can check if the cursor is after the last row the result set.

package org.kodejava.example.sql;

import java.sql.*;

public class ScrollableIsAfterLastExample {
    public static final String URL = "jdbc:mysql://localhost/testdb";
    public static final String USERNAME = "root";
    public static final String PASSWORD = "";

    public static void main(String[] args) throws Exception {
        Connection connection = null;
        try {
            connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);

            Statement statement = connection.createStatement(
            ResultSet resultSet =
                    statement.executeQuery("SELECT * FROM products");

            // Check if we are after the last row in the result set.
            if (resultSet.isAfterLast()) {
                System.out.println("You are after the last row.");
        } catch (SQLException e) {
        } finally {
            if (connection != null) {