Page 1 of 1

Given the code fragment:String query = "SELECT ID FROM Employee"; \\ Line 1try (Statement stmt = conn.CreateStatement()

Posted: Wed Jun 07, 2023 6:11 am
by answerhappygod
Given the code fragment:String query = "SELECT ID FROM Employee"; \\ Line 1try (Statement stmt = conn.CreateStatement()) { \\ Line 2ResultSet rs = stmt.executeQuery(query); \\ Line 3stmt.executeQuery ("SELECT ID FROM Customer"); \\ Line 4while (rs.next()) {\\process the resultsSystem.out.println ("Employee ID: " + rs.getInt("ID") );} catch (Exception e) {system.out.println ("Error");Assume that the SQL queries return records. What is the result of compiling and executing this code fragment?

A. The program prints employees IDs.
B. The program prints customer IDs.
C. The program prints Error.
D. Compilation fails on line 13.