1. Client Java Program
There are many kinds of Java programs like Java bean, Applet, Servlet, EJB, Swing window, etc. Whenever, these Java programs are request the DBMS for database operations these are clients with respect to the database server.
Responsibilities of the client Java program
i. Establishing database connection.
ii. Submitting SQL statements to the DBMS based on the business service the program is handling.
iii. Processing the results that come from the database and presenting them to the end user.
iv. Closing the connection when the database operation are complete
2. JDBC API
In Java, methods are stored in class files. These class files are grouped in packages. JDBC library methods are grouped into 2 packages
i. java.sql
ii. javax.sql
Whenever a Java program wants to communicate with the DBMS it has to make use of the JDBC API. To make these library methods available to the Java program, we need to import these packages.
e.g.: import java.sql.*;
3. DriverManager
- Java program requests the DriverManager for the database connection.
- DriverManager initiates the connection process on the driver.
- Driver establishes the connection with the database server and gives the same to the DriverManager.
- In turn, the DriverManager gives the connection to the Java program.
- Once the Java client program is connected to the database server, DriverManager’s role ends.
4. Driver
- A driver is pre-created translation software that enables Java and database communication in heterogeneous environment.
- A driver developed according to JDBC specification is a JDBC driver.
- JDBC drivers are written in Java.
- They implement JDBC API
Responsibilities of a driver
i. Establishing the Java client – database server connectivity.
ii. Receiving the JDBC method calls from the JDBC application, translating them into DBMS understandable calls and forwarding them to the DBMS.
iii. Receiving the results / response from the DBMS, translating them into Java or JDBC format and returning them to the application.
iv. Indicating the end of the database session of the client to the DBMS.
No comments:
Post a Comment