JDBC is java API that is used to connect and execute query to the database. JDBC API consists of classes and interfaces which are used to communicate with any kind of the database.
Different types of JDBC drivers also developed implementing JDBC API. JDBC API is part of java standard edition (Java SE) and enterprise edition (Java EE).
JDBC driver is software component that enables java application to interact with database. There different drivers available in market targeted for different databases. All JDBC drivers are categorized into following four types.
- JDBC-ODBC Bridge Driver (Type I).
- Native API Driver (Type II).
- Network Protocol Driver (Type III).
- Thin Driver (Type IV).
Below are different Types of JDBC drivers.
JDBC-ODBC Bridge Driver (Type I)
The JDBC-ODBC Bridge driver uses ODBC driver to connect the database. ODBC is the driver for database connectivity since early years and capable of connecting almost any kind of databases. The JDBC-ODBC bridge driver converts JDBC calls to ODBC calls. ODBC driver in turn convert these calls to database specific calls with the help of database library.
- Easy to use.
- Can be used to connect any type of database.
- Performance is less because three conversions are required.
- Data Source Name(DSN) should be provided.
- ODBC driver and Database library are necessary in client machine.
Native API Driver (Type II)
Native API driver uses the client side libraries of database to talk with database. The driver converts JDBC method calls into native calls of the database API. It is partially written in java so also known as partial java driver. Here vendor specific database library is required in client machine.
- Performance is better as compared to type I driver.
- The vendor client library need to be installed in client
- Platform dependent driver because it is not fully written in java
Network Protocol Driver (Type III)
The network protocol driver use middle ware that convert JDBC calls directly or indirectly into the vendor specific database protocol. It is entirely written in java. So it is also called pure java driver for database middle ware. Here same driver can be used for multiple databases. It is used where three tier communication approach is used.
- No need of database vendor specific library in client machine.
- Single driver can handle any database.
- Middle ware also provide facility of caching, load balancing, logging and auditing.
- Database specific coding may be required in middle ware.
- Increased latency due to presence of middle ware.
- Important factor is cost of maintaining application server(Middle ware)
Thin Driver (Type IV)
Type IV driver directly converts JDBC calls directly into vendor specific protocol. It provides better performance as compared to type I or type III drivers. It is entirely written in java. So, this is called pure java driver.
- It is platform independent.
- Better performance than other driver.
- Easy to manage
- Drivers are database dependent so there are separate driver for each database.
First, Driver type I is no more in use.
Secondly, Type III driver is used in large organizations.
Next, Type IV is mostly used
And Finally, Type II may be used where Type IV is not possible to implement.