What is JDBC? No need to learn JDBC

Tram Ho


Currently, most of Java applications or its frameworks are gradually turning to ORM (Object Relational Mapping) to work with the database, which can be mentioned that hibernate is widely used. So people tend to forget about JDBC, but do you know that below hibermate is using JDBC to connect to the database and execute the SQL it generated by it. Back to basic, let’s find out what JDBC is.

JDBC stands for Java Database Connectivity is an API used to connect and execute SQL statements to the database. JDBC API uses JDBC driver to work with database of 4 types.

  • JDBC-ODBC Bridge Driver
  • Native Driver
  • Network Protocol Driver
  • Thin Driver

JDBC architecture

The architecture of JDBC consists of 2 floors:

JDBC API – Allows the application to connect to the JDBC Manager connection. JDBC Driver API: Support JDBC Manager to Driver connection. JDBC API provides connection to different types of database according to a uniform standard.

The JDBC driver makes sure that the JDBC API connects to the database it needs. For each database there will be its own JDBC driver that JDBC API can designate to work with.

The main components in JDBC

The JDBC API provides several classes and interfaces:

DriverManager – This class is responsible for managing the list of database drivers, and is responsible for making the corresponding connection to the specified database specified. Driver – Interface is responsible for handling communication operations between the application and the database. Connection – Interface provides all functions for manipulating the database. Statement – uses objects created from this interface to execute SQL statements into the database. ResultSet: Stores the results returned from the database. SQLException – Handling errors that occur in the database.

Reference source https://shareprogramming.net/jdbc-la-gi-khong-can-hoc-jdbc-dau/

Share the news now

Source : Viblo