JDBC for MySQL - Herong's Tutorial Examples

https://www.herongyang.com/JDBC-MySQL

© 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 MySQL server; using MySQL JDBC driver (MySQL Connector/J); 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

MySQL Installation on Windows

MySQL Installation on macOS

MySQL Installation on Windows

mysqladmin - MySQL Admin Tool

mysql - Command Line Tool

Creating Database and User with MySQL Monitor

MySQL JDBC Driver (MySQL Connector/J)

MySQL Connector/J - Download and Installation

Loading JDBC Driver for MySQL Server

JDBC Driver Connection URL

Specifying Timezone During Connection

Creating Connections with DataSource Class

Getting Driver and Server Information

Creating Tables with AUTO_INCREMENT Columns

"INSERT INTO" Statements

MySQL - PreparedStatement

PreparedStatement Overview

PreparedStatement with Parameters

PreparedStatement in Batch Mode

Performance of Inserting Rows with a PreparedStatement

InnoDB (MySQL 5.5 Default Engine) Slower on INSERT

Performance of Inserting Rows with a Regular Statement

Performance of Inserting Rows with a ResultSet

MySQL - Reference Implementation of JdbcRowSet

Overview of RowSet Objects

Connecting JdbcRowSet to Database Servers

Sun Implementation of JdbcRowSet API

Connecting JdbcRowSet with a Connection URL

Connecting JdbcRowSet with a Predefined Connection Object

Connecting JdbcRowSet with a Predefined ResultSet Object

Connecting JdbcRowSet with JNDI Directory Service

JdbcRowSet Query Statement with Parameters

Inserting Rows with JdbcRowSet Objects

MySQL - JBDC CallableStatement

Overview of CallableStatement Objects

"CREATE PROCEDURE" - Creating a Simple Procedure

Creating Procedures with IN and OUT Parameters

Creating Procedures with INOUT Parameters

Creating Procedures with Multiple Queries

Creating CallableStatement Objects with prepareCall()

Capturing ResultSet with executeQuery()

Creating CallableStatement Objects with Parameters

Common Errors with CallableStatement Parameters

Creating CallableStatement Objects with INOUT Parameters

Retrieving Multiple ResultSet Objects

Executing Stored Procedures without Permission

getProcedures() - Listing Stored Procedures

MySQL CLOB (Character Large Object) - TEXT

Overview of CLOB (Character Large Object)

Create Tables with CLOB Columns

Inserting CLOB Values with SQL INSERT Statements

Inserting CLOB Values with setString() Method

Inserting CLOB Values with setCharacterStream() Method

Retrieving CLOB Values with getString() Method

Retrieving CLOB Values with getCharacterStream() Method

Retrieving CLOB Values with getClob() Method

Inserting CLOB Values with setClob() Method

MySQL BLOB (Binary Large Object) - BLOB

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 12 on Windows

Archived: Java SE 8 Installation

Archived: Java SE 1.6 Update 2 Installation

Archived: JDK 1.6 Documentation Installation

Archived: MySQL Connector/J 5.1 - Download and Installation

Archived: MySQL 5.0 Download, Installation and Start

Archived: mysqladmin - MySQL 5.0 Admin Tool

Archived: MySQL Connector/J 5.0 - Download and Installation

Archived: Loading MySQL Connector Java 5.0

Archived: Installation of JdbcRowSet 1.0 Reference Implementation

References

Full Version in PDF/EPUB

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