What is JDBC?

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 Overview

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 Architecture

The architecture of JDBC-based data connectivity is as follows.

JDBC Architecture | Connect Java applications to Data Sources

JDBC Enabled Application

This is any application written in the Java programming language.

JDBC Driver

Commercial JDBC drivers, or a framework to easily build a JDBC driver, are available from vendors like Simba Technologies.

There are four types of JDBC Drivers in use:

  • JDBC-ODBC Bridge
    A 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.
  • Native API/Partly Java Driver
    A 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.
  • Pure Java Driver
    A 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 and Type 4 drivers.
  • Native Protocol Java Driver
    A Native Protocol Java Driver converts JDBC calls into the database specific calls so that the client applications can communicate directly with the server.

Data Source

A data source is simply the source of the data. It can be a file, a particular database on a DBMS, or even a live data feed. The data might be located on the same computer as the program, or on another computer somewhere on a network.