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

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 Java DB - Derby

Downloading and Installing Java DB (Derby)

Java DB (Derby) in the JDK 1.8 Package

Downloading Java DB (Derby) Documents

"sysinfo" - Checking Java DB (Derby) Installation

Setting Up Java DB (Derby) 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 Java DB (Derby) Network Server

Java DB (Derby) Network Server and JDBC Driver Info

Java DB (Derby) - Creating New Tables

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

Java DB (Derby) - 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?

Java DB (Derby) - 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

Java DB (Derby) - 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

Java DB (Derby) - 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 on Windows

Archived: Java SE 8 Installation

Archived: Java SE 1.6 Update 2 Installation

Archived: JDK 1.6 Documentation Installation

Archived: Downloading/Installing Java DB (Derby) 10.2.2

Archived: "sysinfo" - Checking Java DB Installation 10.2.2

References

Full Version in PDF/EPUB

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