Site icon TestingDocs.com

JDBC API Components [ 2024 ]

JDBC API Components

In this tutorial, you will learn about JDBC API components. JDBC stands for Java Database Connectivity. JDBC API is a collection of classes and interfaces that allow Java applications to interact with databases. 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:

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.

DriverManager

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

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.

Statement

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

Example: stmt.executeQuery(sqlQuery)

ResultSet

The ResultSet interface in JDBC represents the result set of a database query. It refers to the SQL query result and 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