In the previous video we have seen that what are features of Java Swings in short. In this video we are going to learn about JDBC in Java and how does JDBC work in Java programming language.
JDBC is a Java API to connect and execute query with the database.
JDBC API is a Java API that can access any kind of tabular data, especially data stored in a Relational Database. JDBC works with Java on a variety of platforms, such as Windows, Mac Os, and the various versions of UNIX.
The JDBC API supports both two-tier and three-tier processing models for database access but in general, JDBC Architecture consists of two layers.
1. JDBC API
2. JDBC Driver API
JDBC API : This provides the application-to-JDBC Manager connection.
JDBC Driver API : This supports the JDBC Manager-to-Driver Connection.
The JDBC API uses a driver manager and database-specific drivers to provide transparent connectivity to heterogeneous databases.
The JDBC driver manager ensures that the correct driver is used to access each data source.
The driver manager is capable of supporting multiple concurrent drivers connected to multiple heterogeneous databases.
The JDBC API provides the following Interfaces and Classes –
Driver Manager : This class manages a list of database drivers. Matches connection requests from the java application with the proper database driver using communication sub protocol. The first driver that recognises a certain sub protocol under JDBC will be used to establish a database connection.
Driver : This interface handle the communications with the database server. You will interact directly with driver objects very rarely.
Connection : This interface with all methods for contacting a database. The connection object represents communication context.
Statement : We use objects created from this interface to submit the SQL statements to the database. Some derived interfaces accept parameters in addition to executing stored procedures.
Result Set : These objects hold data retrieved from a database after you execute an SQL query using Statement objects. It acts as an iterator to allow you to move through its data.
SQL Exception : This class handles any errors that occur in a database application.
Before JDBC, ODBC API was the database API to connect and execute query with the database. But, ODBC API uses ODBC driver which is written in C language (i.e. platform dependent and unsecured). That is why Java has defined its own API (JDBC API) that uses JDBC drivers (written in Java language).
API (Application Programming Interface) is a document that contains description of all the features of a product or software.
It represents classes and interfaces that software programs can follow to communicate with each other. An API can be created for applications, libraries, operating systems, etc.
So this is what JDBC in Java Programming is. In our next video, we will see what is Java Multiple Catch Block with example.
Have a friend to whom you would want to share this course?