Given the following code snippet and the table, what is the output of the following when using a driver that supports a scroll sensitive ResultSet?.
rst_name last_name //from w ww .j a v a2 s.com character varying(255) character varying(255) Java Server Javascript Client HTML Makup SQL Database try (Connection conn = DriverManager.getConnection(url); Statement stmt = conn.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet rs = stmt.executeQuery( "select * from people order by last_name asc")) { rs.absolute(-1); System.out.print(rs.getString(1)); System.out.print(" "); rs.absolute(1); System.out.print(rs.getString(1)); }
B.
When passing a negative number to absolute()
, Java counts from the end instead of the beginning.
The last row is SQL's row, so the first print statement outputs SQL.
When passing a positive number to absolute()
, Java counts from the beginning, so Java is output.
Option B is correct.