import java.sql.*; public class Example { public static void main(String[] args) { try { Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/mydatabase", "username", "password"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM customers"); // move cursor to last row rs.last(); // get values from last row int id = rs.getInt("id"); String name = rs.getString("name"); double balance = rs.getDouble("balance"); // print values System.out.println("Last customer: " + name + " (id=" + id + ", balance=" + balance + ")"); conn.close(); } catch (SQLException e) { e.printStackTrace(); } } }In this example, we connect to a MySQL database, execute a query to retrieve customer data, and then use the last() method to move the cursor to the last row of the result set. We then retrieve the values from the last row using the various get methods provided by the ResultSet interface. This code uses the java.sql package for working with databases.