JDBC DRIVERS
TYPE 1 JDBC DRIVER (JDBC-ODBC Bridge driver)
This is first driver ever developed.
Driver class of type1 driver software is sun.jdbc.odbc.JdbcOdbcDriver.
This driver receives any JDBC method calls and sends them to ODBC (Open Database
Connectivity) driver. ODBC driver understands these calls and communicate with the
database library provided by the vendor. So the ODBC driver and the vender database
library must be present in client machine.
As type1 driver acts as bridge between sunMicrosystems JDBC technology and microsofts
ODBC technology it is known as JDBC-ODBC bridge driver.
CLIENT MACHINE
SERVER MACHINE
JDBC-ODBC BRIDGE
DRIVER
ODBC DRIVER
DATABASE
SERVER
VENDER DB LIBRARY
TYPE1 JDBC-ODBC BRIDGE DRIVER
ADVANTAGES OF TYPE 1 DRIVER:
It is only driver to communicate with legacy databases.
The JDBC-ODBC Bridge driver allows access to almost all databases since the databases
ODBC drivers are already available in client machine.
DISADVANTAGES OF TYPE 1 DRIVER:
Makes the java application OS dependent (Windows).
The perfermance of this driver is less because the JDBC calls goes through the bdidge
driver to the ODBC driver and then to the native database connectivity library. The result
comes back through reverse process. Tht means in simple word we can say bad
performance due to two layer translation.
Client side maintenance is very high.
Another requirement is that the ODBC driver and the native database connectivity library
must already be installled on the client machine.
Not good for the web.
TYPE 2 JDBC DRIVER (Native API partly java driver)
Type 2 JDBC driver is known as Native API Partly Java Driver.
DBMS vender only develops type 2 driver.
Type 2 driver translates JDBC method calls into DBMS vender provided native library calls.
These native libraries are developed using C or C++ that means a java software known as
Type 2 driver makes use of JNI (Java Native Interfaces) to invoke the native library.
Therefore it is called as Partly Java Driver.
For example oracles OCI driver
Class name = oracle.jdbc.driver.OracleDriver
Connection string = jdbc:oracle:OCI8:@server
CLIENT MACHINE
SERVER MACHINE
NATIVE API PARTLY JAVA
DRIVER
DATABASE SERVER
VENDER DATABASE
LIBRARY
TYPE 2 DRIVER
ADVANTAGES:
Better performance than Type I driver as ODBC layer is completely eliminated and it uses
native API which is database specific.
OS independency is achieved i.e. Type 2 drivers available for all platform of java.
Client side maintenance is slightly reduced.
DISADVANTAGES:
It doesnt provide optimum performance as it doesnt directly communicate with the
database.
Because of native libraries there is a chance of system crash.
Client side maintenance is not completely eliminated. If DBMS product changes, in all client
machines that vender provided native library has to be copied.
The vender database library needs to be loaded on each client machine and hence can not
be used for the internet.
TYPE 3 JDBC DRIVER (Net protocol All java Driver.
Type 3 driver is known as Net Protocol All Java (Pure Java) Driver.
Type 3 driver translates JDBC method calls into a network server understandable protocol
call.
That network server (middleware server) internally uses Type1 or Type 2 driver to
communicate with the DBMS
CLIENT MACHINE
NET
PROTOCOL
PURE JAVA
SERVER MACHINE
MIDDLE
WARE
SERVER
DRIVER
TYPE 3 DRIVER
ADVANTAGES:
DATABASE
SERVER
Zero client side maintenance
Better performance as connection optimization can be done in network server and
protocols are faster.
This driver is server based so there is no need for any vender database library to be
present on the client machine.
This driver is fully written in java and hence portable. It is suitable for the internet.
DISADVANTAGES:
It makes java database communication as 3 tier architecture which is complex to maintain.
Type 3 driver requires database specific coding to be done in the middle tier. Maintenance
of the middle tier becomes costly.
This driver also doesnt directly communicate with the database. Therefore, still there is a
scope for improvement in performance.
TYPE 4 DRIVER (Native Protocol All Java Driver).
Type 4 JDBC driver is also known as Native Protocol All Java Driver.
It translates JDBC method calls into DBMS specific protocol calls so that client applications
can communicate directly with the database setver. For example oracle thin driver
translates JDBC method calls into SQL *NET protocol calls.
TYPE 4 drivers are completely implemented in java to achieve platform independence and
eliminate deployment administration issues. Hence it is most suitable for the web.
ADVANTAGES:
Zero client side maintenance.
Highest performance.
DISADVAANTAGES:
With type 4 driver the user needs a different driver for each database. For example to communicate
with oracle server we need oracle driver and to communicate Sybase server we need Sybase driver.
CLIENT MACHINE
SERVER MACHINE
NATIVE
PROTOCOL PURE
JAVA DRIVER
DATABASE
SERVER
TYPE 4 DRIVER