Java SE 11 Developer (1Z0-819) — Question 202
Examine:
Class.forName(JDBC_DRIVER_CLASS_NAME);
When is it necessary to execute this statement?
Answer options
- A. It must be executed once and only before the first call to DriverManager to get a Connection using the named JDBC driver.
- B. It is no longer required to execute this method.
- C. It must be executed before each call to DriverManager to get a Connection using the named JDBC driver.
- D. It must be executed once and before accessing the named JDBC driver in any way.
Correct answer: B
Explanation
The correct answer is B, as the Class.forName method is not required in newer JDBC versions due to automatic driver loading. Option A is incorrect because it implies a necessity that no longer exists. Option C incorrectly suggests that it must be called repeatedly, and option D also misrepresents the current practice as it suggests a mandatory execution before any driver interaction.