Java OCA OCP Practice Question 2074

Question

What is the correct order to close database resources?.

  • A. Connection then Statement then ResultSet
  • B. ResultSet then Statement then Connection
  • C. Statement then Connection then ResultSet
  • D. Statement then ResultSet then Connection


B.

Note

When manually closing database resources, they should be closed in the reverse order from which they were opened.

This means that the ResultSet object is closed before the Statement object and the Statement object is closed before the Connection object.

This makes Option B the answer.




PreviousNext

Related