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.
Given the code fragment:String query = "SELECT ID FROM Employee"; \\ Line 1try (Statement stmt = conn.CreateStatement()
-
- Site Admin
- Posts: 899566
- Joined: Mon Aug 02, 2021 8:13 am