You are using a database from XY/Data. What is a prerequisite for connecting to the database
using a JDBC 4.0 driver from XY/Data?
A.
Use the JDBC DriverManager.loadDriver method.
B.
Put the XY/data driver into the classpath of your application.
C.
Create an instance of the XY/Data driver class using the new keyword.
D.
Create an Implementation of DriverManager that extends the XY/Data driver
Explanation:
First, you need to establish a connection with the data source you want to use. A
data source can be a DBMS, a legacy file system, or some other source of data with a
corresponding JDBC driver. Typically, a JDBC application connects to a target data source using
one of two classes:
* DriverManager: This fully implemented class connects an application to a data source, which is
specified by a database URL. When this class first attempts to establish a connection, it
automatically loads any JDBC 4.0 drivers found within the class path(B). Note that your application
must manually load any JDBC drivers prior to version 4.0.
* DataSource: This interface is preferred over DriverManager because it allows details about the
underlying data source to be transparent to your application. A DataSource object’s properties are
set so that it represents a particular data source.
Note:The JDBC Architecture mainly consists of two layers:
First is JDBC API, which provides the application-to-JDBC Manager connection.
Second is JDBC Driver API, which supports the JDBC Manager-to-Driver Connection. This has to
provide by the vendor of database, you must have notice that one external jar file has to be there
in class path for forth type of driver (B).
The JDBC API uses a driver manager and database-specific drivers to provide transparent
connectivity to heterogeneous databases. The JDBC driver manager ensures that the correct
driver is used to access each data source. The driver manager is capable of supporting multiple
concurrent drivers connected to multiple heterogeneous databases.
Reference: The Java Tutorials, Establishing a Connection