A JDBC driver enables Java application to interact with a database from where we can fetch or store data. JDBC drivers are analogous to ODBC drivers. The JDBC classes are contained in the Java Package java.sql and javax.sql.JDBC helps to
- Connect to a data source, like a database.
- Send queries and update statements to the database
- Retrieve and process the results received from the database in answer to your query
The Java.sql package that ships with JDK contain various classes with their behaviors defined and their actual implementations are done in third-party drivers. Third-party vendors implement the java.sql.Driver interface in their database driver.
JDBC driver types are used to categorize the technology used to connect to the database.
- Type -1 Bridge driver
- Type -2 Native API
- Type -3 Network Protocol
- Type -4 Native Protocol
Type -3 Driver JDBC is also known as Network Protocol Driver as it uses an application server that converts JDBC calls directly or indirectly into the vendor-specific database protocol. This driver translates JDBC calls into the middleware vendor’s protocol, which is then converted to a database-specific protocol by the middleware server software that provides connectivity to many databases.
Middleware is software that lies between an operating system and the applications running on it. Essentially functioning as a hidden translation layer, middleware enables communication and data management for distributed applications. While all middleware performs communication functions, the type a company chooses to use will depend on what service is being used and what type of information needs to be communicated.
Advantages of Type-3 Driver
- It can be used when the user has multiple databases and want to use a single driver to connect all of them.
- No need to install driver code on the client machine as the Type-3 driver is based on the server.
- The back-end server component is optimized for the operating system on which the database is running.
- Gives better performance than Type 1 and Type-2 drivers.
Disadvantages of Type-3 Driver
- When middleware runs on different machines Type-4 drivers can be more effective.
- It needs database-specific code on the middleware server.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.