JDBC tries to minimize the number of details that a developer needs to worry about. A common approach to this goal is to specify the layers at which various common activities occur and then to tightly define how those layers will interact with one another
and with a program. JDBC takes this approach. JDBC specifies that most of the details about communicating with a database system will be handled through a software layer called a driver.
This driver will handle the details of the three basic tasks we need to do to work with a database:
- Create and maintain a connection to a database
- Send our commands to that database
- Deliver the database response back to our program
A database vendor provides the APIs for accessing the data managed by the database server. A JDBC driver is a middleware used to translate JDBC commands into the vendor's API, send them off to the database, and then return the result.
Despite the fact that database vendors use different APIs, we use a common set of methods to invoke an appropriate JDBC driver. The driver will perform the job of translating to the required API. The JDBC driver performs three different functions in the data request process, as illustrated in the Slide Show below.
The JDBC API includes two major set of interfaces:
- A JDBC API for application developers
- A lower-level JDBC driver API for writing drivers
JDBC drivers are the implementation of the lower-level JDBC driver API as defined in the JDBC specifications. Depending on whether the drivers are implemented using only Java code, native code, or partial Java, they are categorized as follows:
- Type 4.pure Java JDBC driver
- Type 3.pure Java driver for database middleware
- Type 2.native API, partly Java driver
- Type 1.JDBC-ODBC bridge
In the next lesson, you will learn about the four types of JDBC drivers.