Given the code fragment:



Assume that:

The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The Employee and Customer tables are available and each table has id column with a few records and the SQL queries are valid.

What is the result of compiling and executing this code fragment?

A. The program prints employee IDs.
B. The program prints customer IDs.
C. The program prints Error.
D. compilation fails on line 13.

題解

程式第13行,又用了一次Statement物件的executeQuery方法,會使得先前的ResultSet自動被關閉,因此程式第14行會拋出SQLException。