Skip to content
  • Facebook
GeekCer Logo

GeekCer

The geek's Coding education and Review centre

  • Home
  • Tutorials
    • Java
    • Servlet
    • JSP
    • Python
    • C Tutorial
    • Spring
    • Spring Boot
    • MongoDB
    • Hibernate
    • Data Structure
  • General Knowledge
  • Biography
  • Grammar
  • Festival (त्योहार)
  • Interview
  • Differences
  • Important
  • Toggle search form

Home » Java » JDBC Driver in Java

  • International Labour's Day in Hindi | अंतर्राष्ट्रीय मजदूर दिवस 1 मई
    International Labour’s Day in Hindi | अंतर्राष्ट्रीय मजदूर दिवस 1 मई General Knowledge
  • Farmers Day
    National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती General Knowledge
  • Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi
    Jhansi Ki Rani Lakshmi Bai History, Story, Information in Hindi Biography
  • Aranya Kand with Hindi Meaning | अरण्यकाण्ड | सीता हरण
    Aranya Kand with Hindi Meaning | अरण्यकाण्ड का अर्थ | सीता हरण Spiritual
  • World Environment Day in Hindi : Objective, Importance, Theme
    World Environment Day in Hindi : Objective, Importance, Theme General Knowledge
  • What is Tense in Hindi (काल क्या है)?
    What is Tense in Hindi (काल क्या है)? Grammar
  • Hima Das Biography | भारतीय धाविका हिमा दास का जीवन परिचय
    Hima Das Biography | भारतीय धाविका हिमा दास का जीवन परिचय Biography
  • Fundamental Rights of Indian Citizens
    Fundamental Rights of Indian Citizens | मौलिक अधिकार क्या हैं? General Knowledge

JDBC Driver in Java

Posted on August 27, 2021September 5, 2022 By GeekCer Education No Comments on JDBC Driver in Java
JDBC Driver in Java

The Java JDBC driver is an API, or collection of classes and interfaces, that enables programmers to connect to databases, retrieve data from them, and carry out a variety of other database-related tasks.

It is a feature that is essential for the project development since it enables Java program to communicate with any database. Even if you are unfamiliar with database commands, you can still connect with the database. However, updating the database requires modifications to the Java code.

And the most important thing about JDBC driver is that it provides better maintainability of the code on different platforms.

Full form of JDBC is Java Database Connectivity.

Each driver has its own advantages and disadvantages which we will discuss in this article.

Table of Contents

  • Types of JDBC driver in Java
    • Type-1 driver or JDBC-ODBC bridge driver
      • Advantages of JDBC-ODBC bridge driver
      • Disadvantages of JDBC-ODBC bridge driver
    • Type-2 driver or Native API driver
      • Advantages of Native API Driver
      • Disadvantages of Native API Driver
    • Type-3 driver or Network protocol driver
      • Advantages of Network protocol driver
      • Disadvantages of Network protocol driver
    • Type-4 driver or Pure java driver (Thin driver)
      • Advantages of Thin driver
      • Disadvantages of Thin driver
  • Why didn’t Sun adopt the ODBC model?
  • Ultimate goal of the JDBC

Types of JDBC driver in Java

There are four types of JDBC drivers which are as follows:

Type-1 driver or JDBC-ODBC bridge driver

JDBC-ODBC bridge driver or Type-1 driver depends on the ODBC driver, it receives any JDBC calls and sends them to the ODBC driver, and then ODBC communicates with the database library when it understands it. In other words, to communicate with database it converts the JDBC calls to ODBC function calls.

Advantages of JDBC-ODBC bridge driver

  • It is database dependent driver.
  • Very easy to use.
  • It allows access to almost all the database.

Disadvantages of JDBC-ODBC bridge driver

  • Performance of this driver is not much good.
  • We need to install on client machine.

Type-2 driver or Native API driver

The type-2 driver, which communicates directly with the database server, helps the database library in converting JDBC classes into database-specific calls. This makes sense when applied to the database directly.

Therefore, the client computer must have some binary code that facilitates communication with the server.

Advantages of Native API Driver

  • It offers better performance than JDBC-ODBC bridge driver.
  • Type-2 does not require an ODBC driver.

Disadvantages of Native API Driver

  • It is vender specific driver.
  • You need to load library on each client machine.
  • You cannot use type-2 driver for the internet.
  • It is not a portable driver because it is not written in Java.

Type-3 driver or Network protocol driver

The Type-3 driver is independent of the database and is a pure Java client library. It follows a three-tiered approach. It uses a middle tier server, which translates the JDBC calls into a database specific library and sends it to the database server. In other words, the request is sent through the network to the server machine and then to the database server.

Advantages of Network protocol driver

  • It is portable driver because it is written in java.
  • There is no requirement of vendor specific library.

Disadvantages of Network protocol driver

  • Client machine required network support.
  • We need to change middle tier code if we change the database.
  • Maintenance is very costly,

Type-4 driver or Pure java driver (Thin driver)

Type 4 Driver is a pure Java library that directly translates JDBC calls into database-specific DBMS protocols. It helps the client to communicate directly with the database server.

Mostly, we use type-4 driver on the internet.

Advantages of Thin driver

  • It provides better performance than all other drivers.
  • It is portable because it is completely written in Java.
  • There is no need to install any library on the client system.

Disadvantages of Thin driver

  • The main disadvantage of this driver is that it is database dependent. We need database specific driver. For example, if we are using Oracle then we have to use Oracle driver, if we are using MySql database then we have to use MySql driver.

Why didn’t Sun adopt the ODBC model?

  • ODBC is hard to learn and it has some commands with lots of complex options.
  • ODBC relies on the use of void* pointers.
  • It uses C features that are not inherent in the Java programming language, so it can be difficult for Java programmers.
  • An ODBC-based solution is less safe and harder to deploy than a pure Java solution.

Ultimate goal of the JDBC

The JDBC specification actually allows you to pass any string to the underlying driver. The driver can pass any string to the database.

Programmers can write applications in the Java programming language to access any database, using standard SQL as well as using extensions to SQL.

In conclusion, if you got the idea about the JDBC driver then your next step should be the java connectivity with database. Hope you liked the article of JDBC driver in Java. Feel free to contact on geekcer.code@gmail.com or you can write a comment if you have any doubt and query.

Share this:

  • Click to share on Facebook (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
  • Click to share on Twitter (Opens in new window)
  • More
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Pinterest (Opens in new window)

Also Read

Java

Post navigation

Previous Post: Exception Handling in Java
Next Post: Steps of Database Connectivity in Java

More Related Articles

Internal Working of HashMap in Java | Rehashing , Hash Collision Internal Working of HashMap in Java, Rehashing, Collision Java
Lambda Expression in Java 8 | Functional Interface | Example Lambda Expression in Java 8 | Functional Interface | Example Java
Immutable class in Java Immutable class in Java | How to create Immutable class in Java Important
Collections in Java Collections in Java Java
Java ArrayList Java ArrayList Java
Java Vector Vector in Java Collection, Constructors, Example Programs Java

Leave a Reply Cancel reply

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

  • Java Home
  • Java Comments
  • Java Variables
  • Java Data Types
  • Java Keywords
  • Java Operators
  • Java If-else Statement
  • Java Switch
  • Java Loop
  • Java Arrays
  • Method Overloading in Java
  • Java OOP
  • Java Collections
  • Java ArrayList
  • Java LinkedList
  • Java Vector
  • Multithreading in java
  • Thread Synchronization
  • Exception Handling
  • Java JDBC Driver
  • Java Database Connectivity steps
  • Lambda Expressions
  • Concurrent Collections
  • National Farmers Day in Hindi | राष्ट्रीय किसान दिवस पर निबंध | चौधरी चरण सिंह जयंती
  • Human rights day in Hindi: 10 दिसंबर ह्यूमन राइट्स डे
  • Unicef day is celebrated on December 11 | Speech on unicef day
  • Indian Navy Day: जल सेना दिवस कब और क्यों मनाया जाता है?
  • P V Sindhu Biography in Hindi, Badminton, State, Caste पी. वी. सिंधु जीवन परिचय, कहानी, राज्य, जाति
  • Draupadi Murmu Biography In Hindi | द्रौपदी मुर्मू की जीवनी
  • IPv4 Vs IPv6 | Difference between IPv4 and IPv6
    IPv4 Vs IPv6 | Difference between IPv4 and IPv6 Differences
  • Similarities and difference between OSI and TCP/IP model
    OSI vs TCP/IP Model, Similarities and difference between OSI and TCP/IP model Networking
  • Network kya hai (नेटवर्क क्या है)
    Network kya hai (नेटवर्क क्या है) Networking
  • OSI Model | 7 Layers of OSI Model in Computer network
    OSI Model | 7 Layers of OSI Model in Computer network, Functions Networking
  • Difference between Internet and Intranet
    Difference between Internet and Intranet Differences
  • TCP/IP Model, Full Form, Layers and their Functions
    TCP/IP Model, Full Form, Layers and their Functions Networking
  • Difference between TCP and UDP
    Difference between TCP and UDP | TCP vs UDP examples Differences
  • Java Tutorial
  • Servlet Tutorial
  • JSP Tutorial
  • Maven Tutorial
  • HTML Tutorial
  • Programs
  • Hindi/English Grammar
  • Difference Between ... and ...
  • HR Interview
  • Important Articles

Write to Us:
geekcer.code@gmail.com

  • About Us
  • Privacy and Policy
  • Disclaimer
  • Contact Us
  • Sitemap

Copyright © GeekCer 2022 All Rights reserved