Home           J2EE Concepts           JMS           Java Language           Contact           Back           Next           Bookmark this Page          










Some useful tips related to:
 - health & fitness
 - vehicle care
 - cooking
 - misc household tasks

Types of JDBC drivers


There are four types of JDBC drivers:
Type 1 - JDBC-ODBC bridge plus ODBC driver.
Type 2 - Native-API, partly Java driver.
Type 3 - JDBC-Net, pure Java driver.
Type 4 - Native-protocol, pure Java driver.
- Create the connection.



Type 1 Drivers


These types of drivers convert JDBC calls to ODBC (Open Database Connectivity ) calls; and then ODBC carries over those calls to the database; i.e. the control flow would look like following: Client (Java Code) -> JDBC Driver -> ODBC Driver -> Database
The driver is implemented in the sun.jdbc.odbc.JdbcOdbcDriver class and comes with the Java 2 SDK, Standard Edition
Advantages:
- Simplest driver. Very easy to use.
Disadvantages:
- Performance overhead due to extra conversion layers.
- ODBC driver must be installed on the machine.
- Restricted to Microsoft platform.
- Not suited for applets, because that would require the driver to be installed on client side.



Type 2 Drivers


Also known as Native-API drivers. These use client-side libraries of the database; i.e. the driver's Java code calls native ( C, C++ etc.) code provided by various vendors that perform the database access.
Advantages:
- Better performing that Type 1 drivers.
Disadvantages:
- Vendor client library must be installed on the machine; and all vendors do not provide library.
- Not suited for applets, because that would require the driver to be installed on client side.



Type 3 Drivers


Also known as the network-protocol driver. These drivers use a middle-tier between the program and the database. The middle-tier (application server) converts JDBC calls directly or indirectly into the vendor-specific database protocol.
Advantages:
- No need for the vendor library on the client machine.
- Middleware doesn't need to be changed for a new database.
Disadvantages:
- Introduces an extra layer.
- Requires DB specific coding in middleware.



Type 4 Drivers


Also known as the native-protocol driver. These are completely written in Java & hence they're platform independent. Using network protocols built into the database engine, type 4 drivers talk directly to the database using Java sockets. This means a direct call from client to DB server; i.e. the control flow would be something like: Client Machine -> Type 4 JDBC Driver -> DBMS
Advantages:
- Since there is no middleware or client API for DB involved so performance is considerably improved.
-
Disadvantages:
- A separate driver is needed at client side for each database.
- It may not be suitable for applications where the underlying protocol does not handle issues such as security and network connectivity well.