import java.sql.*; public class ScrollableResultSetExample { public static void main(String[] args) { String url = "jdbc:mysql://localhost:3306/your_database"; String username = "root"; String password = "your_password"; try { Connection connection = DriverManager.getConnection(url, username, password); String query = "SELECT * FROM your_table"; Statement statement = connection.createStatement( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = statement.executeQuery(query); if (resultSet.last()) { System.out.println(resultSet.getString("column_name")); } if (resultSet.first()) { System.out.println(resultSet.getString("column_name")); } resultSet.close(); statement.close(); connection.close(); } catch (SQLException e) { e.printStackTrace(); } } }