JDBC Tutorials - Herong's Tutorial Examples

https://www.herongyang.com/JDBC

Copyright © 2003-2024 Herong Yang. All rights reserved.

JDBC Tutorials This JDBC tutorial book is a collection of notes and sample codes written by the author while he was learning JDBC technology himself. Topics include installing JDK and Derby database server; using Derby JDBC driver; database connection URLs; introduction to Result Set; Meta Data, Prepared Statement, CLOB, and BLOB; connection pooling with DBCP and C3P0. Updated in 2024 (Version v3.13) with minor changes.

Table of Contents

About This Book

JDBC (Java Database Connectivity) Introduction

What Is JDBC?

JDBC Version and History

JDBC Driver Types

Establishing Connections from JDBC to Databases

DriverManager - Loading JDBC Driver

DriverManager - Connection URL

JDK (Java SE) Installation

Downloading and Installing JDK on Windows

Adding JDK "bin" Directory to Path Setting

Downloading and Installing JDK on Mac

Downloading and Installing JDK on Linux

Compile and Run Java Programs

-cp or -classpath Syntax on Different Systems

JDK Documentation Installation

Installing and Running Derby (Java DB)

Downloading and Installing Derby (Java DB)

Derby (Java DB) in the JDK 1.8 Package

Downloading Derby (Java DB) Documents

"sysinfo" - Checking Derby (Java DB) Installation

Setting Up Derby (Java DB) in Network Server

"ij" - Client Tool to Create New Databases

Derby (Java DB) JDBC Driver

Derby (Java DB) Driver Features

Loading Derby JDBC Driver Classes

Creating Connections to Derby (Java DB) Network Server

Derby (Java DB) Network Server and JDBC Driver Info

Derby (Java DB) - Creating New Tables

Derby (Java DB) - Inserting Data Rows to Existing Tables

Derby (Java DB) - Running SELECT Queries

Derby (Java DB) JDBC DataSource Objects

Derby - Connection with DataSource Objects

Derby - Using ClientDataSource Directly

Installing JNDI File System Service Provider

Derby - Storing ClientDataSource Objects on File System

Derby - Looking Up ClientDataSource Objects on File System

What Happens If Client JDBC DataSource JAR Is Missing?

Derby (Java DB) - DML Statements

Tables with Primary Key Column "GENERATED ... AS IDENTITY"

"INSERT INTO" Statements

"INSERT INTO" Statements with INDENTITY Columns

Handling Date and Timestamp Values

"UPDATE" Statements

"DELETE FROM" Statements

Derby (Java DB) - ResultSet Objects of Queries

What Is ResultSet?

ResultSet Cursor and Scrollability

ResultSet Cursor Initial Position: Before First Row

Retrieving Column Values with getXXX() Methods

ResultSet Default Type: Forward-only

Scrollable ResultSet and Moving Cursor Backward

ResultSet Objects with Update Capability

insertRow() - Inserting New Rows through ResultSet Objects

updateXXX() - Updating Column Values for Row Update or Insert

deleteRow() - Deleting Rows through ResultSet Objects

Derby (Java DB) - PreparedStatement

PreparedStatement Overview

PreparedStatement with Parameters

PreparedStatement in Batch Mode

Performance of Inserting Rows with a PreparedStatement

Performance of Inserting Rows with a Regular Statement

Performance of Inserting Rows with a ResultSet

Summary of JDBC Drivers and Database Servers

List of Tested JDBC Drivers

Connection URL Formats and Examples

Implementations of the DataSource Interface

Performances on Inserting Rows

Using Connection Pool with JDBC

What Is Database Connection Pool

Commons DBCP for Connection Pooling

Connection Pooling with Commons DBCP BasicDataSource

Connection Pooling with Commons DBCP PoolingDriver

C3P0 for Connection Pooling

Connection Pooling with C3P0 ComboPooledDataSource

Connection Pooling with C3P0 DataSources

Archived Tutorials

Archived: Downloading and Installing JDK 13 on Mac

Archived: Downloading and Installing JDK on Windows

Archived: Java SE 8 Installation

Archived: Java SE 1.6 Update 2 Installation

Archived: JDK 1.6 Documentation Installation

Archived: Downloading/Installing Derby (Java DB) 10.2.2

Archived: "sysinfo" - Checking Java DB Installation 10.2.2

References

Full Version in PDF/EPUB

Keywords: JDBC, Java, Database, Derby, Tutorial, Example