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

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899559
Joined: Mon Aug 02, 2021 8:13 am

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

Post 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.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!

This question has been solved and has 1 reply.

You must be registered to view answers and replies in this topic. Registration is free.


Register Login
 
Post Reply