What Is JDBC?

JDBC (Java DataBase Connectivity) is the specification of the standard application programming interface that provides a standard library for accessing relational databases like MS Access, Oracle, or Sybase. It also provides a common base on which higher-level tools and interfaces can be built. It is an application programming interface that defines how a Java programmer can access the database in tabular format from Java code using a set of standard interfaces and classes written in the Java programming language.

How JDBC Helps us?

How To Implement JDBC API?

The implementation of the JDBC API can only be possible through JDBC Drivers. The API interface is made up of 4 main interfaces:

Architecture of JDBC Driver

JavaArch

Types of JDBC Drivers

Diagrammatical representation of the different JDBC Drivers

JDBCDriver

Types of JDBC SQL Statements

  1. java.sql.Statement: Topmost interface, which provides basic methods useful for executing SELECT, INSERT, UPDATE, and DELETE SQL statements.
  2. java.sql.PreparedStatement: An enhanced version of java.sql.Statement, which allows precompiled queries with parameters.
  3. java.sql.CallableStatement: It allows you to execute stored procedures within an RDBMS that supports stored procedures.

How to use JDBC?

Brief description of another widely used interface: ODBC

ODBC

ODBC is the most widely used interface to access the database. It is a multi-database API for programs that use SQL statements to access data. With the use of ODBC, we can access any data from any application regardless of which database management system (DBMS) is handling the data. We cannot use ODBC directly with Java programs; rather, we have to make use of JDBC with ODBC to develop Java database applications.

Difference between JDBC and ODBC

JDBC ODBC
Definition Java Database Connectivity API for data connections
for Data and Java Class.
Object Database Connectivity driver for Microsoft
specification and desktop applications.
Design Simple design with advanced capabilities available. Mixes simple and advanced features together and has complex options for simple queries.
Language JDBC drivers are written in Java. ODBC is not dependent upon any language.
Installation JDBC code is automatically installable, secure, and portable on all platforms. Requires manual installation of the ODBC driver manager and driver on all client machines.


The architecture of ODBC Driver

ODBCDriver

ODBC Driver