Which of the following can be independently inserted into the blank so the code can run without error for at least one SQL query?
private static void choices(Connection conn, String sql) throws SQLException { try (Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(sql)) { } }
next()
; System.out.println(rs.getInt(1));next()
) System.out.println(rs.getInt(1));D.
The most common approach is III, which works for any SELECT statement that has an int in the first column.
If the SELECT statement has a function like count(*) or sum(*) in the first column, there will always be a row in the ResultSet, so II works as well.
Therefore, Option D is the answer.