Choose the correct option based on the following code snippet.
Assume that DbConnector.connectToDb()
returns a valid Connection object and that the EMPLOYEE table has a column named CUSTOMERID
of type VARCHAR(3)
.
ResultSet resultSet = null;/*from ww w. j a v a2s . c o m*/ try (Connection connection = DbConnector.connectToDb()) { // LINE_ONE Statement statement = connection.createStatement(); resultSet = statement.executeQuery ("SELECT * FROM CUSTOMER WHERE CUSTOMERID = 1212"); // LINE_TWO } while (resultSet.next()){ // LINE_THREE resultSet.getString("CUSTOMERID"); }
f)
the try-with-resources block is closed before the while statement executes.
hence, call resultSet.next()
results in making a call on the closed ResultSet object, thereby throwing an SQLException.