Java Database Connectivity
Java Database Connectivity | |
---|---|
Basic data
|
|
developer | Sun Microsystems |
Current version | 4.3 (September 21, 2017) |
operating system | Java |
programming language | Java |
category | Programming interface |
License | GNU General Public License / Java Community Process |
oracle.com |
Java Database Connectivity ( JDBC , English for Java database connectivity ) is a database interface of the Java platform, which offers a uniform interface to databases from different manufacturers and is specially designed for relational databases .
In its function as a universal database interface, JDBC is comparable to e.g. B. ODBC under Windows or DBI under Perl .
The tasks of JDBC include establishing and managing database connections, forwarding SQL queries to the database, converting the results into a form that can be used by Java and making them available to the program.
Each specific database requires its own drivers that implement the JDBC specification . These drivers are usually supplied by the manufacturer of the database system.
JDBC is part of the Java Standard Edition since JDK 1.1. The JDBC classes are in the Java packages java.sql
and javax.sql
. Since JDBC 3.0, JDBC has been further developed as part of the Java Community Process . JSR 221 is the specification for version JDBC 4.0; currently 4.3 (part of Java SE 9).
Types of JDBC drivers
The JDBC specification distinguishes between different types of JDBC drivers.
Type 1 driver
A JDBC type 1 driver only communicates via a JDBC-ODBC bridge driver. The best-known JDBC-ODBC bridge is the one distributed by Oracle. A type 1 driver is therefore dependent on an installed ODBC driver. The JDBC-ODBC bridge driver converts JDBC into ODBC requests.
A type 1 driver is used if there is an ODBC driver for the database, but no stand-alone JDBC drivers.
With Java 9, support for JDBC Type 1 drivers will be discontinued.
Type 2 driver
A type 2 driver communicates with the database server via a platform-specific program library on the client. This means that an additional program library is required for the type 2 driver for each operating system platform.
Type 3 driver
Using the type 3 driver, the JDBC API commands are translated into generic DBMS commands and transmitted (via a network protocol) to a middleware driver on an application server. Only this application server transforms the commands for the specific database server and forwards them to them. A type 3 driver therefore does not need any platform-specific libraries and does not need to know anything about the database server used.
Type 3 drivers are very suitable for Internet protocols in connection with firewalls .
Type 4 driver
With the type 4 driver, the JDBC API commands are translated directly into DBMS commands of the respective database server and transferred to it (via a network protocol). A middleware driver is not used. This means that a type 4 driver can be faster than a type 3 driver, but it is less flexible.
Type 4 drivers are well suited for intranet solutions that want to use fast network protocols.
Web links
- Official JDBC home page (English)
- JDBC Tutorial (English)
- List of available JDBC drivers for Oracle databases
- JSR 221 (English)