Pages Navigation Menu

Coding is much easier than you think

JDBC Tutorial for beginners

JDBC
 
JDBC is a Java API that enables Java application to connect and execute query to the database. JDBC API uses jdbc drivers to connect to the database.

This tutorial will not cover every single detail of the JDBC API, but focus on the most commonly used features. Here you will learn many step by step examples on using JDBC Statement, PreparedStatement, CallableStatement, and JDBC Transaction.

The rest you can read about in the JavaDoc afterwards.

Happy learning :-)
 

Quick Start

Some quick guides to show how JDBC interact with databases like MySQL, Oracle and PostgreSQL.

 

JDBC & Statement interface

 

JDBC & PreparedStatement interface

The PreparedStatement interface is a sub interface of Statement. It is used to execute parameterized query.

Why use PreparedStatement?

You can use a PreparedStatement instead of a Statement and benefit the following features of the PreparedStatement.
The PreparedStatement’s primary features are:

  1. Easy to insert parameters into the SQL statement.
  2. Easy to reuse the PreparedStatement with new parameters.
  3. Increase performance of executed statements  because query is compiled only once.
  4. Enables easier batch updates.

 

 

JDBC & Stored Procedure

 

JDBC Batch Update example

 

JDBC Performance Tuning

 

FAQ