Exam 1z0-819 All QuestionsBrowse all questions from this exam
Question 197

Examine:

Class.forName(JDBC_DRIVER_CLASS_NAME);

When is it necessary to execute this statement?

    Correct Answer: B

    With the introduction of JDBC 4.0, which is included in Java 6 and later, manually loading the driver class with Class.forName() is no longer necessary. The JDBC drivers are automatically discovered and registered by scanning for service providers on the classpath, provided that the driver's JAR file is included. Thus, Class.forName(JDBC_DRIVER_CLASS_NAME); is not required to connect using the named JDBC driver.

Discussion
d7bb0b2Option: B

However, since JDBC 4.0 (which is included in Java 6 and later), JDBC drivers are automatically discovered and registered by scanning for service providers on the classpath. This means that you no longer need to manually load the driver class with Class.forName() as long as the driver's JAR file is on the classpath.