Introduction JDBC API

Introduction JDBC API
When we need to use database drivers and the JDBC API while developing a Java application to retrieve or store data in database. The JDBC API classes and interfaces are available in the java.sql and the javax.sql package. The classes and interfaces perform a number of tasks, such as establish and close a connection with a database, send a request to a database, retrieve data from database, and update data in the database.
The commonly used classes and interfaces in the JDBC API are:
1. DriverManager class: It Load the driver for a database.
2. Driver interface: It represents a database driver. All JDBC driver classes must implement the Driver interface.
3. Connection interface: It enables to establish a connection between a Java application and a database.
4. Statement interface: It enables to execute SQL statements.
5. ResultSet interface: It represents the information retrieve from a database.
6. SQLException class: It provides information about the exception that occurs while interacting with database.
To query a database and display the result using Java applications, we need to:
a. Load a Driver
b. Connect to a database
c. Create and execute JDBC statements
d. Handle SQL exceptions