Java Database Connectivity (JDBC), from the Oracle Corporation, is a specification for an application program interface (API) that allows Java applications to access multiple database management systems using Structured Query Language (SQL). The JDBC Driver Manager handles multiple drivers that connect to different databases.
A set of interfaces is included in the standard JDBC API and the JDBC Standard Extension API so you can open connections to databases, execute SQL commands, and process results. The interfaces are described in Table 1-1.
Interface |
Description |
---|---|
java.sql.Driver |
Locates the driver for a database URL |
java.sql.Connection |
Used to connect to a specific database |
java.sql.Statement |
Executes SQL statements |
java.sql.PreparedStatement |
Handles SQL statements with parameters |
java.sql.CallableStatement |
Handles database stored procedure calls |
java.sql.ResultSet |
Gets the results of SQL statements |
java.sql.DatabaseMetaData |
Used to access information about a connection to a database. |
java.sql.ResultSetMetaData |
Used to access information describing the attributes of a ResultSet. |
javax.sql.Rowset |
Handles JDBC RowSet implementations. |
javax.sql.DataSource |
Handles connection to a data source. |
javax.sql.ConnectionPoolDataSource |
Handles connection pools. |
Each relational database management system requires a driver to implement these interfaces. There are four types of JDBC drivers:
Type 1 JDBC-ODBC bridge – translates JDBC calls into ODBC calls and passes them to an ODBC driver. Some ODBC software must reside on the client machine. Some client database code may also reside on the client machine.
Type 2 native-API partly-Java driver – converts JDBC calls into database-specific calls. This driver, which communicates directly with the database server, also requires some binary code on the client machine.
Type 3 net-protocol all-Java driver – communicates to a middle-tier server using a DBMS-independent net protocol. A middle-tier gateway then converts the request to a vendor-specific protocol.
Type 4 native-protocol all-Java driver – converts JDBC calls to the vendor-specific DBMS protocol, allowing client applications direct communication with the database server.
For more information about JDBC and its specification, see the Oracle Technology Network for Java.