JDBC Drivers helps in interacting with databases. JDBC driver manager makes sure that correct driver is used to access each data source. There are 4 types of JDBC drivers :
- Type 1 : JDBC-ODBC Bridge Driver
- Type 2 : Native API Driver (partially java driver)
- Type 3 : Network Protocol or Net Pure Driver (fully java driver)
- Type 4 : Thin Driver (100% pure java driver)
Now we will discuss all of these 4 types in detail :
Type 1 : JDBC-ODBC Bridge Driver
This driver uses ODBC driver installed on client machine to make connection to data source. In order to use this driver, we need to configure Data Source Name (DSN) on our machines which represents target database. This is the oldest driver we have and it is not much in use. Moreover, support for this driver has been stopped from Java 8.
There are few disadvantages of using this driver :
Type 2 : Native API Driver
When we use this driver JDBC calls are converted into native C/C++ calls. This driver is not entirely written in Java. These drivers are used in same manner as JDBC-ODBC Bridge. These drivers are vendor specific and needs to be installed on each client machine. If we change the database then we need to change the native API library as well.
Performance with these drivers are upgraded as compared to JDBC-ODBC Bridge. There are some disadvantages as well :
There are few disadvantages of using this driver :
- Performance of the applications gets degraded as the JDBC calls gets converted into ODBC class for executing SQL statements.
- ODBC driver needs to be installed on client machine.
- Support for this driver is ended in Java 8
Type 2 : Native API Driver
When we use this driver JDBC calls are converted into native C/C++ calls. This driver is not entirely written in Java. These drivers are used in same manner as JDBC-ODBC Bridge. These drivers are vendor specific and needs to be installed on each client machine. If we change the database then we need to change the native API library as well.
Performance with these drivers are upgraded as compared to JDBC-ODBC Bridge. There are some disadvantages as well :
- These needs to be installed on each client machine.
- In addition to drivers vendor specific API also needs to be installed on client machine.
Type 3 : Network Protocol or Net Pure Driver
These drivers are purely written in Java language. These drivers used a 3-tier architecture for communication with databases. Most of DB related tasks are handled by a middleware server which converts JDBC calls directly or indirectly into vendor specific database protocol.
These drivers are very flexible as compared to previous drivers because it does not require any code to be installed on client machine.
.
Type 4 : Thin Driver (100% Pure Java Driver)
This is a pure Java-based driver, which communicates directly with vendor's database through socket connection. Performance wise this is the best driver to choose. This driver doesn't require any native database library for interaction with database. Moreover, we don't need to install any kind of special software on client or server machine.
Which driver to should be used and when?
If we are accessing one type of database, such as Oracle, MySQL, Sybase etc. then we should use Type 4 driver.
If our Java Application is accessing multiple types of databases at same time then, we should use Type 3 driver.
If neither Type 4 nor Type 3 is available for the database used by our application then we should go for Type 2 driver.
We should not use Type 1 for deployment purpose, it should be only used for development and testing purposes only.
These drivers are very flexible as compared to previous drivers because it does not require any code to be installed on client machine.
.
Type 4 : Thin Driver (100% Pure Java Driver)
This is a pure Java-based driver, which communicates directly with vendor's database through socket connection. Performance wise this is the best driver to choose. This driver doesn't require any native database library for interaction with database. Moreover, we don't need to install any kind of special software on client or server machine.
Which driver to should be used and when?
If we are accessing one type of database, such as Oracle, MySQL, Sybase etc. then we should use Type 4 driver.
If our Java Application is accessing multiple types of databases at same time then, we should use Type 3 driver.
If neither Type 4 nor Type 3 is available for the database used by our application then we should go for Type 2 driver.
We should not use Type 1 for deployment purpose, it should be only used for development and testing purposes only.
No comments:
Post a Comment