JDBC drivers allow you to connect to any type of database. There are 4-types of JDBC drivers available, out of which Type-1 and Type-4 is used extensively. This article will cover the introductory part of JDBC drivers. So let’s start the discussion from the JDBC API in short.
JDBC (Java Database Connectivity)
JDBC stands for Java Database connectivity. It is used to connect java application & database.JDBC API uses queries & updates to database through java application. Java & JDBC API is platform & vendor independent. JDBC API uses java.sql & javax.sql as primary packages. JDBC can read any tabular data, including data in relational databases.
JDBC comes up with four components: JDBC API, Driver Manager, Driver Test Suite & Type-1driver.
In Short: JDBC API allows programmer to access database. Driver manager connect java application to JDBC driver. Driver test suite ensures that JDBC runs your program. Type-1 driveralso called as JDBC-ODBC Bridge which allows JDBC drivers to access ODBC API.
Why we need JDBC?
JDBC API provides connectivity between java application & database. JDBC driver does the job of bridge between java application & database.
What is JDBC driver?
JDBC driver is a program that converts java method calls to the corresponding method calls understandable by database in use.
Types of JDBC Driver
There are four types of JDBC drivers which allow java application the ability to access database.There is ambiguity for figures of JDBC drivers so I’ve avoided using them here. You can search over Google & consult with sun reference specification for the accurate figures.
1. Type 1 Driver
This is also known as JDBC- ODBC Bridge. This driver is automatically installed when J2SDK is installed on your machine. This driver is used as bridge between JDBC & ODBC API. What is ODBC? ODBC is a driver manager in windows platform. It can be accessed through Control panel> Administrative tools> ODBC (Data Sources). It is used to manage drivers for SQL based databases. ODBC is designed by Microsoft for windows only platform. So it has few limitations like: Platform dependent, Speed etc..
2. Type 2 Driver
This is also known as Native API partly java driver. This API is designed to overcome the platform dependent limitation of type 1 driver. This driver is partly written in java & partly written in native API code. It installs platform specific code to client computer in addition to the java library. Limitation of this driver is that installs he platform specific code on client computer.
3. Type 3 Driver
This driver is known as Net protocol all java drivers. It uses database independent protocol to communicate DB-request to a server component. Server component translates request to DBspecific protocol. Type 3 driver internally uses either type1 or type 2 driver to connect to the database. As client is independent of actual DB deployment, this method is simple & more flexible.
4. Type 4 Driver
This driver is also known as Native protocol pure java driver. It is also called as “Thin” Driver. It is much faster than type1 & type 2 drivers. This driver directly converts all java method calls to database calls. So with help of this driver, Client machine or application server makes direct calls to DBMS server. Most of the Proprietary database vendors do have Type 4 drivers. Type-4 drivers are popular for faster performance and direct access to DBMS features.
You can get more information about JDBC from following resources:
Javaranch forums/Saloon | Oracle Sun Microsystems’s JDBC documentation Page
I hope information above helped. If you’ve any suggestions or feedback regarding this article then please do not hesitate to submit.