Java SE 8 Programmer II — Question 21
Which action can be used to load a database driver by using JDBC3.0?
Answer options
- A. Add the driver class to the META-INF/services folder of the JAR file. jdbc.properties file.
- B. Include the JDBC driver class in a java.lang.Class.forName method to load the driver class.
- C. Use the DriverManager.getDriver method to load the driver class.
- D. Use the
Correct answer: B
Explanation
The correct answer is B because the java.lang.Class.forName method is specifically designed to dynamically load classes at runtime, which is essential for loading the JDBC driver. Option A is incorrect as it relates to a different configuration method, while Option C refers to a method that does not directly load the driver class like Class.forName does. Option D is incomplete and does not provide any actionable information.