MySQL Connector/J 8.0 Developer Guide

Abstract

This manual describes how to install, configure, and develop database applications using MySQL Connector/J 8.0, a JDBC and X DevAPI driver for communicating with MySQL servers.

MySQL Connector/J 8.0 is highly recommended for use with MySQL Server 8.0, 5.7, 5.6, and 5.5. Please upgrade to MySQL Connector/J 8.0.

For notes detailing the changes in each release of Connector/J 8.0, see MySQL Connector/J 8.0 Release Notes.

For legal information, including licensing information, see the Preface and Legal Notices.

For help with using MySQL, please visit either the MySQL Forums or MySQL Mailing Lists, where you can discuss your issues with other MySQL users.

Document generated on: 2018-12-18 (revision: 60396)


Table of Contents

Preface and Legal Notices
1 Overview of MySQL Connector/J
2 Connector/J Versions, and the MySQL and Java Versions They Support
3 What's New in Connector/J 8.0?
4 Connector/J Installation
4.1 Installing Connector/J from a Binary Distribution
4.2 Installing the Driver and Configuring the CLASSPATH
4.3 Upgrading from an Older Version
4.3.1 Upgrading to MySQL Connector/J 8.0
4.4 Installing from the Development Source Tree
4.5 Testing Connector/J
5 Connector/J Examples
6 Connector/J Reference
6.1 Driver/Datasource Class Name
6.2 Connection URL Syntax
6.3 Configuration Properties
6.4 JDBC API Implementation Notes
6.5 Java, JDBC, and MySQL Types
6.6 Using Character Sets and Unicode
6.7 Connecting Securely Using SSL
6.8 Connecting Using Unix Domain Sockets
6.9 Connecting Using Named Pipes
6.10 Connecting Using PAM Authentication
6.11 Using Master/Slave Replication with ReplicationConnection
6.12 Mapping MySQL Error Numbers to JDBC SQLState Codes
7 JDBC Concepts
7.1 Connecting to MySQL Using the JDBC DriverManager Interface
7.2 Using JDBC Statement Objects to Execute SQL
7.3 Using JDBC CallableStatements to Execute Stored Procedures
7.4 Retrieving AUTO_INCREMENT Column Values through JDBC
8 Connection Pooling with Connector/J
9 Multi-Host Connections
9.1 Configuring Server Failover
9.2 Configuring Client-Side Failover when using the X Protocol
9.3 Configuring Load Balancing with Connector/J
9.4 Configuring Master/Slave Replication with Connector/J
9.5 Advanced Load-balancing and Failover Configuration
10 Using the Connector/J Interceptor Classes
11 Using Connector/J with Tomcat
12 Using Connector/J with JBoss
13 Using Connector/J with Spring
13.1 Using JdbcTemplate
13.2 Transactional JDBC Access
13.3 Connection Pooling with Spring
14 Troubleshooting Connector/J Applications
15 Known Issues and Limitations
16 Connector/J Support
16.1 Connector/J Community Support
16.2 How to Report Connector/J Bugs or Problems
Index

List of Tables

2.1 Summary of Connector/J Versions
4.1 Changes with the Build Properties from Connector/J 5.1 to 8.0
4.2 Changes with the Test Properties from Connector/J 5.1 to 8.0
4.3 Changes for Exceptions from Connector/J 5.1 to 8.0
6.1 Possible Conversions Between MySQL and Java Data Types
6.2 MySQL Types and Return Values for ResultSetMetaData.GetColumnTypeName()and ResultSetMetaData.GetColumnClassName()
6.3 MySQL to Java Encoding Name Translations
6.4 Mapping of MySQL Error Numbers to SQLStates

List of Examples

7.1 Connector/J: Obtaining a connection from the DriverManager
7.2 Connector/J: Using java.sql.Statement to execute a SELECT query
7.3 Connector/J: Calling Stored Procedures
7.4 Connector/J: Using Connection.prepareCall()
7.5 Connector/J: Registering output parameters
7.6 Connector/J: Setting CallableStatement input parameters
7.7 Connector/J: Retrieving results and output parameter values
7.8 Connector/J: Retrieving AUTO_INCREMENT column values using Statement.getGeneratedKeys()
7.9 Connector/J: Retrieving AUTO_INCREMENT column values using SELECT LAST_INSERT_ID()
7.10 Connector/J: Retrieving AUTO_INCREMENT column values in Updatable ResultSets
8.1 Connector/J: Using a connection pool with a J2EE application server
14.1 Connector/J: Example of transaction with retry logic