JDBC Chapters


Introduction to JDBC

JDBC Stands for Java Database Connectivity

JDBC  is a API or Bridge  that allows Java programs to exchange data with database systems.


JDBC allows user to send SQL, PL/SQL statements to almost any database and exchange data.

SQL language is prominently used for working with JDBC.

Java application calls the JDBC library. JDBC loads a driver which talks to the database.

JDBC classes & interfaces are contained within the java.sql package



For any further quires do write us to madhusudan@javaconceptz.com

Types of JDBC Drivers

Types of Drivers

Before JDBC API database connectivity was tedious (not simple) and cumbersome.

Most of libraries provided for database connectivity were vendor specific and can operate with database provided by vendor or support was specific to databases only.If in case when user changes database or driver used the application then access portions has to changed accordingly.

Let us discuss Few types of drivers used

  1. JDBC-ODBC bridge driver ( Type 1 driver)
  2. Native API/ Partly Java driver ( Type 2 driver)
  3. Network Protocol driver ( Type 3 driver)
  4. Pure Java driver ( Type 4 driver)

To connect with individual databases, JDBC requires drivers for each database and were provided by different vendors. The JDBC driver gives out the connection to the database and implements the protocol for transferring the query and result between client and database.

Currently We are using Type 4 driver for development of all enterprise projects and I advise all the developers or learners to use Type 4 driver.

Note : For Interview purpose go through about other drivers (Type 1,Type 2 & Type 3)

JDBC-ODBC bridge driver ( Type 1 driver)

Type 1 driver converts all JDBC calls into ODBC calls and sends them to the ODBC driver.ODBC communicates with the database.
ODBC (Open Database Connectivity ) is a generic API.

The JDBC-ODBC Bridge driver is recommended only for experimental use or when no other alternative is available.


  • The JDBC-ODBC Bridge allows accessing any database, since the database’s ODBC drivers are already available in the server


  • Since the Bridge driver is not written fully in Java, Type 1 drivers are not portable.
  • A performance issue is seen as a JDBC call goes through the bridge to the ODBC driver, then to the database, and this applies even in the reverse process. They are the slowest of all driver types.
  • The client system requires the ODBC Installation to use the driver.
  • Not good for the Web.

Native API/ Partly Java driver ( Type 2 driver)

Type 2 drivers convert JDBC calls into database-specific calls i.e. this driver is specific to a particular database and it is provided by vendor.

For Example: Oracle will have oracle native API as provided by vendor.


  • Since the no of layer communication is less the performance of Type2 driver is much better than JDBC-ODBC bridge driver.


  • Portability issue Since Type2 driver is not written in java language
  • If we change the database we need to change native API.
  • Type 2 driver cannot be for internet. Since Native API is installed on Client Machine
  • Usually not Thread safe and is almost obsolete or not available

Network Protocol driver( Type 3 driver)

Type 3 driver sends client requests to middle-tier server which contains Native Driver. The middle-tier then sends the request to the database.


  • This driver is server-based, so there is no need for any vendor database library to be present on client machines.
  • Driver is fully written in Java and hence Portable. It is suitable for the web.
  • The net protocol can be designed to make the client JDBC driver very small and fast to load and typically provides support for features such as caching (connections, query results, and so on), load balancing, and advanced system administration such as logging and auditing.
  • This driver is very flexible allows access to multiple databases using one driver and is most efficient.


  • It requires another server application to install and maintain which is costlier process.
  • Since the details have to pass from Middleware server it takes more time to process the result which is cumbersome.

Pure Java driver( Type 4 driver)

The Type 4 uses java networking libraries to communicate directly with the database server. This driver is also called as Thin Driver.


  • The major benefit of using type 4 jdbc drivers are that they are completely written in Java and it is portable.
  • To achieve platform independence and eliminate deployment administration issues.
  • It is most suitable for the web.
  • Number of translation layers is very less i.e. type 4 JDBC drivers don’t have to translate database requests to ODBC or a native connectivity interface or to pass the request on to another server, performance is typically quite good.
  • We don’t need to install special software on the client or server. Further, these drivers can be downloaded dynamically.


  • With type 4 drivers, the user needs a different driver for each database. ( Example for oracle Database : ojdbc14.jar )

Leave a Reply

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