Java Database Connectivity (JDBC)

Java applications cannot communicate directly with a RDBMS to submit data and retrieve the results of queries. This is because a RDBMS can interpret only SQL statements and not the Java language statements. So, we need some kind of mechanism to translate Java statements into SQL statements. In Java programming domain, the technology that enables database access and manipulation is called Java Database Connectivity (JDBC).

JDBC has two parts: the JDBC core API and the JDBC optional package API. The JDBC Core API is the main part of JDBC and it takes the form of the classes and interfaces in the java.sql package. The JDBC optional package API is specified in the javax.sql package and it supports connection pooling, distributed transactions, row sets, and so forth.

 

JDBC Architecture

The JDBC architecture provides a mechanism to translate Java statements into SQL statements. The JDBC architecture can be categorized into two layers — (1) JDBC API Layer and (2) JDBC Driver API Layer. The description of JDBC architecture is given here. See Figure below for detailed information.

Figure 1: JDBC Architecture

1) JDBC API Layer: It signifies a Java application that uses the JDBC API to interact with the JDBC drivers. A JDBC driver is software that a Java application uses to access a database. The JDBC driver manager of JDBC API connects the Java application to the driver.

2) JDBC Driver API Layer: It acts as an interface between a Java application and a database. This layer contains a driver, such as   a MySQL driver or an Oracle driver, which enables connectivity to a database. A driver sends the request of a Java application to the database. After processing the request, the database sends the response back to the driver. The driver translates and sends the response to the JDBC API. The JDBC API forwards it to the Java application.

 

Significance of Database Driver

When we develop JDBC applications, we need to use JDBC drivers to convert queries into a form that a particular database can interpret. The JDBC driver also retrieves the result of SQL statements and converts the result into equivalent JDBC API class objects that the Java application uses. As the JDBC driver only takes care of interactions with the database, any change made to the database does not affect the application.

 

 

Java Database Connectivity (JDBC)

 Advanced Java Programming
 Java Enterprise Edition Architecture
 Java Servlets

Servlet Advantages

Servlet Application Architecture

Servlet Container

Steps to develop Servlet Code

Servlet Hierarchy & API

Servlet Life Cycle

ServletConfig & ServletContext

Servlet Session Management

getRequestDispatcher() & sendRedirect()
ServletContext, Session & Request attributes
 JavaServer Pages (JSP)
JSP Advantages
JSP Application Architecture
JSP Tags
Steps to develop JSP Code
JSP Comparison with Servlet
JSP becomes Servlet
JSP API
JSP Life Cycle
JSP Implicit Objects
JSP with JavaBeans
JSP Programming Examples
JSP Standard Tag Library (JSTL)
 Java Database Connectivity (JDBC)
JDBC Architecture
JDBC Driver Types
JDBC API
Steps to develop JDBC Code
JDBC Methods Comparison
JDBC PreparedStatement
JDBC CallableStatement
JDBC Connection Pooling
 Model-View-Controller (MVC)
MVC Architecture with Apache Struts 1
MVC Architecture with Apache Struts 2
Java Database Connectivity (JDBC)

Java applications cannot communicate directly with a RDBMS to submit data and retrieve the results of queries. This is because a RDBMS can interpret only SQL statements and not the Java language statements. So, we need some kind of mechanism to translate Java statements into SQL statements. In Java programming domain, the technology that enables database access and manipulation is called Java Database Connectivity (JDBC).

JDBC has two parts: the JDBC core API and the JDBC optional package API. The JDBC Core API is the main part of JDBC and it takes the form of the classes and interfaces in the java.sql package. The JDBC optional package API is specified in the javax.sql package and it supports connection pooling, distributed transactions, row sets, and so forth.