Explain JDBC architectures and components with suitable and brief description.
JDBC Architecture
The JDBC API supports both two-tier and three-tier processing models for database access but in general JDBC Architecture consists of two layers:
a) JDBC API: This provides the application-to-JDBC Manager connection.
b) JDBC Driver API: This supports the JDBC Manager-to-Driver Connection.
Description:
Application: It is a java applet or a servlet that communicates with a data source.
The JDBC API: The JDBC API allows Java programs to execute SQL statements and retrieve results. Some of the important classes and interfaces defined in JDBC API are as follows:
- DriverManager
- Driver
- Connection
- Statement
- PreparedStatement
- CallableStatement
- ResultSet
- SQL data
DriverManager: It plays an important role in the JDBC architecture.It uses some database-specific drivers to effectively connect enterprise applications to databases.
JDBC drivers: To communicate with a data source through JDBC, you need a JDBC driver that intelligently communicates with the respective data source.
Common JDBC Components
The JDBC API provides the following interfaces and classes:
DriverManager: This class manages a list of database drivers. Matches connection requests from the java application with the proper database driver.
Driver: This interface handles the communications with the database server. We interact directly with Driver objects very rarely. Instead, we use DriverManager objects, which manage objects of this type. It also abstracts the details associated with working with Driver objects.
Connection: This interface with all methods for contacting a database. All communication with the database is done through the connection object only.
Statement: We use objects created from this interface to submit the SQL statements to the database.
ResultSet: These objects hold data retrieved from a database after we execute an SQL query using Statement objects. It acts as an iterator to allow us to move through its data.
SQLException: This is the subclass of the Exception class and handles any errors that occur in a database application.
OR,
Components of JDBC
There are generally four main components of JDBC through which it can interact with a database. They are as mentioned below:
JDBC API: It provides various methods and interfaces for easy communication with the database. It provides two packages as follows which contain the java SE and Java EE platforms to exhibit WORA(write once run everywhere) capabilities.
1. java.sql.*;
2. javax.sql.*;
It also provides a standard to connect a database to a client application.
JDBC Driver manager: It loads a database-specific driver in an application to establish a connection with a database. It is used to make a database-specific call to the database to process the user request.
JDBC Test suite: It is used to test the operation(such as insertion, deletion, updation) being performed by JDBC Drivers.
JDBC-ODBC Bridge Drivers: It connects database drivers to the database. This bridge translates the JDBC method call to the ODBC function call.It makes the use of
sun.jdbc.odbc
the package that includes a native library to access ODBC characteristics.
Comments
Post a Comment