Types of JDBC Drivers

JDBC and JDBC Drivers

Java Data Base Connectivity (JDBC) is an Application Programming Interface which is one of important usable in different business applications. The reason behind the widely use of JDBC is that because most of the business application software use database. 

jdbc drivers types

In order to retrieve and store the  data in database through GUI we need some kind of connectivity between front end database . Java Data Base Connectivity (JDBC) connects java application with database.

JDBC Drivers

JDBC API Package is java.sql and we imports this package in our jdbc application program. In this package there  are many interfaces. To connect java application  with any database we require a jdbc driver which implements all the interfaces provided in sql package.

Java provides jdbc-odbc bridge driver. It uses ODBC drivers available on your machine. It has limited operations. So it is not suitable for production environment.

Types of jdbc drivers in java

Different types of jdbc drivers in java with examples are as follow:

Type 1 JDBC Driver

java database connectivity steps

The type 1 JDBC driver, JDBC-ODBC Bridge simply  translates all JDBC calls into ODBC (Open DataBase Connectivity)  and send them to ODBC Driver. Advantage of type 1 jdbc odbc driver is that it is easy to use and can be connected to any database but it’s Performance can be degrades because type 1 jdbc driver calls are converts into odbc function calls.

Type 2 JDBC Driver

Second type of JDBC drivers is the native-API/partly Java driver which converts JDBC calls into database specific calls for the databases. Example of such database are  SQL Server, Informix, Oracle or SybaseThis type of driver communicates directly with the database server. It requires that some binary code be present on the client machine.

advantages of jdbc drivers

Advantage of type 2 jdbc driver is that it provide better performance as compare to type 1 jdbc odbc bridge. This type of driver  Need  Vendor library and native driver should be installed on client computer.

Type 3 JDBC Driver

JDBC driver type 3 driver is the net-protocol/all-Java driver  and its architecture is based on three-tiered approach where at first  JDBC database requests are passed through the network to the middle-tier server.
Now this middle tier server  translates the received request either directly or indirectly to the database-specific native connectivity interface to further the request to the database server.

jdbc connectivity stpes
Advantages of using this type of driver is that there is no need of client side library because application server itself perform many tasks.If the middle-tier server is written in java then it can use Type 1 and Type 2 Driver also.

Type 4 JDBC Driver

JDBC driver type 4  is the native-protocol/all-Java driver which converts JDBC calls into the vendor specific database management system (DBMS) protocol.It make it easy for  client applications to communicate directly with the database server. 
Type 4 drivers are completely developed  in Java . Advantage of this is that it achieve platform independence and eliminate deployment administration issues.

jdbc steps
Advantages of Type 4 driver is that it gives better performance as compare to all other drivers and there is also no need of client and server side driver. But  it is database dependent.

Next : – jdbc steps to connect database in java

Leave a Reply

Your email address will not be published. Required fields are marked *