Java Database Connectivity (JDBC) is an API specification for connecting applications written in Java to data in popular databases. The JDBC API lets you encode access request statements in Structured Query Language (SQL) that are then passed to the application that manages the database. It returns the results through a similar interface. JDBC is very similar to ODBC, and with a small "bridge" program, you can use the JDBC interface to access databases through the ODBC interface. For example, you could write an application designed to access many popular database products on a number of operating system platforms.
JDBC is an API developed by Sun Microsystems to enable a standards-based method to access data using the Java language. As is the case with ODBC, JDBC enables a single JDBC application to access a number of data sources and can run on any machine with a Java Virtual Machine (JVM). The JDBC data standard defines a set of Java interfaces to enable application developers abstract data access functionality including:
- Establish Connection with a data source
- Execute SQL queries
- Process result sets
The architecture of JDBC-based data connectivity is as follows.
JDBC Enabled Application
This is any application written in the Java programming language.
Commercial JDBC drivers, or a framework to easily build a JDBC these driver, are available from vendors like Simba Technologies.
JDBC Driver Types
There are four types of JDBC Drivers in use:
Type 1: JDBC-ODBC Bridge
A Type 1 JDBC-ODBC Bridge provides application developers with a way to access JDBC drivers via the JDBC API. Type 1 JDBC drivers translate the JDBC calls into ODBC calls and then sends the calls to the ODBC driver. Type 1 JDBC drivers are generally used when the database client libraries need to be loaded on every client machine.
Type 2: Native API/Partly Java Driver
A Type 2 Native API/Partly Java Driver is a partial Java driver because it converts JDBC calls into database specific calls. Type 2 Native API/Partly Java Driver communicates directly with the database server.
Type 3: Pure Java Driver
A Type 3 Pure Java Driver works in a three tiered architecture. The JDBC calls are passed via the network to the middle tier server. This server translates the calls to the database specific native interface to further request the server. JDBC drivers available from Simba are Type 3 drivers.
Type 4: Native Protocol Java Driver
A Type 4 Native Protocol Java Driver converts JDBC calls into the database specific calls so that the client applications can communicate directly with the server.
The data source consists of the data the user wants to access and its database management system.