JDBC | Introduction to Java Database Connectivity

What is JDBC?

JDBC stands for Java Database Connectivity. It is a step by step procedure to communicate with the database from the Java application in order to perform database operation. Basically, JDBC is an Application Programming Interface (API) that makes it possible to standardize and simplify the process of connecting Java applications to a database.

What are the different types of JDBC drivers?

As we have understood, JDBC is used to connect Java applications with the database. We should also know that JDBC uses different JDBC drivers to perform this task. Basically, a JDBC driver is a software component which enables Java applications to interact with the database.

  • Native-API Driver (partially Java driver)
  • Network Protocol Driver (fully Java driver)
  • Thin Driver (fully Java driver).

How JDBC works

  • It allows to send queries and updates statements
  • It helps to fetch the data from the database and process the fetched results.

Why JDBC is needed?

It is important to understand why we need Java Database connectivity. Java applications are required to connect with database. Java applications are written in Java programming language, but the database only understands Structured Query Language (SQL). In order to establish a connection between Java application and database, JDBC is used. JDBC contains a set of interface and classes which helps to connect Java application to the database.

JDBC components:

Let us discuss 6 main components of JDBC:

  1. Driver: Driver is the interface which manages the communications happening between the application and the database server.
  2. Connection: Connection is an interface which contains methods for contacting the database.
  3. Statement: Statement is an interface that creates an object to submit SQL queries or statements to the database.
  4. Result Set: Result Set contains the results that are retrieved from the database after the execution of SQL statements or queries.
  5. SQL Exception: SQL Exception class is used to handle any of the errors that occur in a database application.

Which Database is best suited for Java?

As there are number of databases available which help to develop software projects on Java, it is difficult to say which is the best database among all of them. There are various factors involved while choosing a right database to develop a software application. For example, you have to consider whether you are looking for an open source database or a paid version of database, or if you want to use a cloud based database matters.

  1. MySQL
  2. PostgreSQL
  3. IBM-DB2
  4. MS-SQL

Advantages of Java Database Connectivity:

Java Database Connectivity comes up with several advantages, some of them are:

  1. JDBC supports modules
  2. JDBC provides better security
  3. JDBC completely supports query and stored procedure
  4. JDBC supports both types of processing i.e. Synchronous and Asynchronous processing
  5. JDBC does not require content conversion.


JDBC is a very important concept which every Java developer needs to understand to develop projects. We hope this blog helps our reader to understand various concepts related to JDBC.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store