Site icon TestingDocs.com

JDBC API Components

Overview

In this tutorial, we will learn about JDBC API components. JDBC API is a collection of classes and interfaces that provide database access. Using the JDBC API, we can access any database. The core JDBC API is comprised of two main packages. We automatically get both packages when we download Java on the machine. The two packages are as follows:

 

 

🛠️ JDBC Components

The main JDBC API Components are as follows:

1️⃣ JDBC Driver

A JDBC driver is a software component that implements the JDBC API for a specific database system. For example, MySQL JDBC driver for Java programming language is MySQL Connector/J

MySQL Connector/J is the official JDBC driver for the MySQL database. It allows Java applications to connect to and interact with the MySQL database. Different types of JDBC drivers are available.

2️⃣ DriverManager

DriverManger manages the JDBC drivers and establishes the connection to the database. It uses the JDBC URL to establish the connection to the database. It returns the Connection object on a successful database connection.

3️⃣ Connection

The Connection object represents the session to the connected database. The createStatement() method creates a Statement object to send SQL statements to the database.

4️⃣ Statement

The Statement object executes the SQL statements and returns the SQL query results.

Example: stmt.executeQuery(sqlQuery)

5️⃣ ResultSet

The ResultSet object refers to the SQL query result table. It maintains a cursor pointing to the current row. We can iterate through the ResultSet using a while loop to get the data.

Java Tutorials

Java Tutorial on this website:

For more information on Java, visit the official website :

More information about Oracle Database:

Exit mobile version