Type 2 Driver

Type 2 Driver

In this tutorial, we are going to discuss about the Type 2 Driver in JDBC. Type 2 driver is also known as Native API -Partly Java Driver OR Native Driver.

Type 2 Driver

Type 2 Driver is exactly same as Type 1 Driver except that ODBC Driver is replaced with Vendor specific Native Libraries. Type-2 Driver internally uses Vendor specific Native Libraries to Communicate with Database.

Native Libraries means the Set of Functions written in Non-Java (Mostly C OR C++). We have to install Vendor provided Native Libraries on the Client Machine. Type 2 Driver converts JDBC Calls into Vendor specific Native Library Calls, which can be understandable directly by Database Engine.

Advantages
  • When compared with Type 1 Driver Performance is High, because it required only one Level Conversion from JDBC to Native Library Calls.
  • No need of arranging ODBC Drivers.
  • When compared with Type-1 Driver, Portability is more because Type 1 Driver is applicable only for Windows Machines.
Limitations
  • Internally this Driver using Database specific Native Libraries and hence it is Database Dependent Driver. Because of this migrating from one Database to another Database will become Difficult.
  • This Driver is Platform Dependent Driver.
  • On the Client Machine compulsory we should install Database specific Native Libraries.
  • There is no Guarantee for every Database Vendor will provide This Driver.

(Oracle People provided Type-2 Driver but MySQL People won’t provide this Driver)

Example : OCI (Oracle Call Interface) Driver is Type-2 Driver provided by Oracle.

OCI Driver internally uses OCI Libraries to communicate with Database. OCI Libraries contain “C Language Functions”.

OCI Driver and corresponding OCI Libraries are available in the following Jar File. Hence we have to place this Jar File in the Class Path.

ojdbc14.jar âž” Oracle 10g (Internally Uses Java 1.4V)
ojdbc6.jar âž” Oracle 11g (Internally Uses Java 1.6V)
ojdbc7.jar âž” Oracle 12c (Internally Uses Java 1.7V)

Note

The only Driver which is both Platform Dependent and Database Dependent is Type-2 Driver. Hence it is not recommended to use Type 2 Driver.

That’s all about the Type 2 Driver in JDBC. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!!

Type 2 Driver
Scroll to top