Updated April 17, 2023
Introduction to JDBC
JDBC driver is defined as a software module which allows the java application to cooperating with the database. We have five types of JDBC drivers today which helps to apply the definite interfaces in the JDBC API to interrelate with the database server. For instance, suppose by means of the JDBC drivers we are able to open any database connection, interrelate with it by transferring SQL or database queries and then accepting outcomes with Java. Here, many classes having their respective definite behaviour where their authentic applications are completed in third party drivers, present in a Java.sql package which is shipped with JDK. Further, the Java.sql.Driver interfaces are implemented in their database driver by the third-party vendors.
Various JDBC Types
It may vary the implementations of JDBC driver due to the inclusive diversity of OS and hardware platforms which involves operating Java. JDBC drivers are said to be the client-side adapters that is installed on the client machine but not on the server which helps to transform requests from Java programs to a protocol that can be understandable by DBMS.
JDBC drivers types that are applicable in the industry:
- JDBC-ODBC bridge Driver
- Partial Java Driver (Native API Driver)
- Pure Java Driver Hosted for Database Middleware (or, Network Protocol Driver)
- Pure Java Driver Hosted for Direct to Database (or, Native Protocol Driver)
- Highly Functional Drivers having Superior Presentation
But when we concern about choosing the best one among these five kinds of JDBC types for most applications, we must select a pure one that is Java driver, i.e. either the type 3, 4 or 5.
- The JDBC drivers of type 1, are implemented to check JDBC applications alongside an ODBC data source. The JDBC drivers of type 2, need a built-in database API to be implemented. Both JDBC drivers of Type 1 and Type 2 combine a Java-based API with other API. Therefore, we can also have JDBC drivers of four types only.
- The JDBC type 3, is the only JDBC driver applied to access and enter a middleware server that in turn, creates the appropriate calls to the database. If we see an example which is good of Type 3 JDBC driver then, it is DataDirect SequeLink JDBC driver.
- The JDBC drivers of Type 4, are the most corporate as well as considered for a distinct vendor’s database. Whereas, the JDBC drivers like DataDirect JDBC drivers of Type 5, deliver progressive functionality and greater performance in excess of other types of JDBC drivers.
JDBC is part of the Java Standard Edition platform introduced by Oracle Corporation where it functions as an internal layer interface between the java applications and database. Here, the JDBC classes are included in the package of Java such as javax.sql and java.sql.
1. JDBC-ODBC Driver
This is considered as a Type 1 JDBC bridge driver that uses the ODBC driver for connecting to the database. The JDBC-ODBC bridge driver transforms the calls of the JDBC method into the calls of the ODBC function. Since this type 1 driver can be associated with any database, thus this is also known as the Universal driver.
- Since this may be a mutual driver implemented for communicating with many databases, so the data conveyed may be not secure.
- It is required for the ODBC driver to be set up in each client machine.
- Type 1 driver is not scripted in Java hence, not portable.
- Being built-in with JDK, this driver software is not required to be installed distinctly.
- This is database independent type, driver.
2. Native API Driver
This type 2 driver applies the libraries of the database of client-side transforming the calls of the JDBC method into the database API’s native calls. As it uses its local API to connect with several databases, so the data conveyed is much secure.
- It is required to be set up in each client machine.
- The vendor-client library is required to be set up on each client machine.
- Type 2 driver is not scripted in Java hence, not portable.
- This is database dependent driver.
3. Network Protocol Driver
The type 3 driver implements an application server i.e. middleware, which transforms JDBC calls into the vendor detailed protocol of the database either directly or indirectly. In one server, all the connectivity of database drivers is available, not requiring client-side installation distinctly.
- Written in Java entirely, hence portable ones.
- Application server performing different tasks such as logging, auditing, load balancing, etc. hence, no need for a client-side library.
- On the client machine, the network support may be needed.
- The cost of maintenance increases, as it needs database-specific coding in the middle tier.
- Switching over from one database to the other one is possible due to the switch facility.
4. Native Protocol Driver
This type 4 driver communicates with the database directly, no need for any native database library. Hence, it is also said to be the Thin driver.
- No need for any Middleware server or the native library, therefore no installation is required for the client-side or server-side.
- Transcribed in Java completely, hence they are portable ones.
We can apply the drivers according to as:
- For accessing a single database like Oracle, IBM, Sybase, then we can choose a type 1 driver.
- For accessing many databases by the Java application at the same time, then type 3 is chosen.
- If type 3 or 4 is not present in any situations, then type 2 drivers are helpful.
- Type 1 driver is used basically only to develop and test tasks since it is not measured as a deployment level driver.
Conclusion – JDBC Types
Java Database Connectivity is known as an application programming interface i.e. API designed for the popular programming language, Java that states how a client can access somewhat type of tabular data, particularly relational databases. Thus, JDBC assists to write Java applications which controls the three activities of programming containing open connectivity to the database, transfer of queries, fetch data records from the database server as result or update them through SQL commands.
This is a guide to JDBC Types. Here we discuss the introduction along with various JDBC types for a better understanding. You may also have a look at the following articles to learn more –