English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JDBC Tutorial

The JDBC API is a Java API that can access any type of tabular data, especially data stored in relational databases. JDBC can be used with Java on various platforms, such as Windows, Mac OS, and various UNIX versions.

Why learn JDBC?

JDBC stands forĴ AVA d ATA b ASE Ç Connectivity, which is a standard Java API for independent connections between Java programming language and a wide range of databases.

The JDBC library includes APIs for each task mentioned below, which are usually associated with database usage.

  • Establish a connection with the database.

  • Create SQL or MySQL statements.

  • Execute SQL or MySQL queries in the database.

  • View and modify result records.

Applications of JDBC

In essence, JDBC is a specification that provides a complete set of interfaces, allowing portable access to the underlying database.Java can be used to write different types of executable files, such as-

  • Java Application

  • Java Applet

  • Java Servlet

  • Java ServerPage (JSP)

  • Enterprise JavaBean (EJB).

All these different executable files can be accessed by JDBC drivers to access databases and utilize the stored data.

JDBC provides the same functionality as ODBC, allowing Java programs to include database-independent code.

JDBC 4.0 package

java.sql and javax.sql are the JDBC 4.0 main package.This is the latest JDBC version at the time of writing this tutorial.It provides the main classes for interacting with data sources.

The new features in these software packages include changes in the following aspects:

  • Automatic Loading of Database Drivers.

  • Improvements in Exception Handling.

  • Enhanced BLOB / CLOB Functionality.

  • Enhanced Connection and Statement Interfaces.

  • National Character Set Support.

  • SQL ROWID Access.

  • SQL 2003 XML Data Type Support.

  • Annotations.

Target Audience

This tutorial is designed for Java programmers who want to gain a detailed understanding of the JDBC framework, its architecture, and its practical usage.

Prerequisites

You should have a good understanding of the Java programming language before continuing with this tutorial.You should be familiar with SQL and database concepts before handling RDBMS.