Which two actions can be used in registering a JDBC 3.0 driver?

Which two actions can be used in registering a JDBC 3.0 driver?

Which two actions can be used in registering a JDBC 3.0 driver?

A.
Add the driver class to the META-INF/services folder of the JAR file.

B.
Set the driver class name by using the jdbc.drivers system property.

C.
Include the JDBC driver class in a jdbcproperties file.

D.
Use the java.lang.class.forName method to load the driver class.

E.
Use the DriverManager.getDriver method to load the driver class.

Explanation:

A: if your JDBC Driver is NOT JDBC 4-compliant then we can update the driver using “jar”-utility
by adding the
“META-INF /services/java.sql.Driver” inside it. as following:
D:Dynamic loading of Java classes at runtime provides tremendous flexibility in the development
of enterprisesystems. It provides for the basis of “application servers”, and allows even simpler,
lighter-weight systems toaccomplish some of the same ends. Within Java, dynamic-loading is
typically achieved by calling the forNamemethod on the class java.lang.ClassAn example provided
by the standard Java SE API is the ServiceLoader. Amongothers, the JDBC 4.0compatible drivers
implement this. This way just dropping the JDBC driver JAR file folder will automatically loadthe
driver class during Java application’s startup/initialization without the need for any manual
Class.forName(“com.example.Driver”) line in your code.



Leave a Reply 8

Your email address will not be published. Required fields are marked *


l0c

l0c

I agree, from reading the documentation Luiz provided. Other sites claim it should be AD.

gelete

gelete

A False

OCA/OCP Java SE7 Programmer I & II Study Guide
860 Chapter 15: JDBC

We talked about how the DriverManager will scan the classpath for JAR files that
contain the META-INF/services/java.sql.Driver file and use a classloader to
load those drivers. This feature was introduced in the JDBC 4.0 specification.

Priorto that, JDBC drivers were loaded manually by the application.