JDBC – Type 1 Driver
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 -1 Driver JDBC driver also known as bridge driver it provides a bridge to access the ODBC driver installed on each client. Type 1 drivers translate calls to JDBC methods into calls to Open Database Connectivity (ODBC) functions. Bridge drivers allow JDBC applications immediate access to database connectivity provided by the existing array of ODBC drivers.
ODBC is based on the device driver model, where the driver encapsulates the logic needed to convert a standard set of commands and functions into the specific calls required by the underlying system. Using the JDBC-ODBC bridge driver we can access the databases which support only ODBC. Java application sends a request to the JDBC-ODBC bridge driver the request internally calls the ODBC equivalent function and the ODBC driver retrieves the result from the underlying database and sends it back to the JDBC-ODBC bridge driver.
Advantages of Bridge driver
- Different Data Sources can be accessed by this single driver only.
- All ODBC supported databases are supported
- JAVA application should be dependent only on the ODBC driver
- On every client, you need to install ODBC to make Type- 1 driver work
- JDBC method call is converted to ODBC calls this degrades its performance
An easy way to learn JDBC. It can be useful for companies that already have ODBC drivers installed on each client machine usually Windows-based machines that run production processes. It may be the only way to access certain low-level desktop information. But not for large scale application. Performance suffers because there is a higher standard associated with translation work from JDBC to ODBC. It does not support all Java features. User is limited to ODBC driver base functionality.
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.