JDBC API Components
Overview
Let’s learn JDBC API Components in this tutorial. 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 the Java on the machine.
The two packages are as follows:
java.sql.*;
javax.sql.*;
JDBC Components
The main JDBC API Components are as follows:
- DriverManager
- Connection
- Statement
- ResultSet
- ResultSet Metadata
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.
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 is used for executing the SQL statements and returns the SQL query results.
Example: stmt.executeQuery(sqlQuery)
ResultSet
The ResultSet object refers to the SQL query result table. The ResultSet object maintains a cursor pointing to the current row of the query result table. We can use a while loop to iterate through the ResultSet.
—
Oracle Database Tutorials on this website:
https://www.testingdocs.com/oracle-database-tutorials-for-beginners/
More information about Oracle Database: