Read this section only if you want to build a customized version of Connector/J from source, or if you are interested in helping us test our new code. To just get MySQL Connector/J up and running on your system, install Connector/J using a standard binary release distribution; see Section 4.1, “Installing Connector/J from a Binary Distribution” for instructions.
To install MySQL Connector/J from source, make sure that you have the following software on your system:
It is suggested that the latest versions available for the following software be used for compiling Connector/J; otherwise, some features might not be available.
A Git client, if you want to check out the sources from our GitHub repository (available from http://git-scm.com/downloads).
Apache Ant version 1.10.6 or newer (available from http://ant.apache.org/), and the Ant JUnitLauncher (
ant-junitlauncher-1.10.6.jar, available from, for example, the Maven Central Repository at https://search.maven.org/artifact/org.apache.ant/ant-junitlauncher/1.10.6/jar).
JDK 1.8.x (available from https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html).
The following third-party libraries:
JUnit 5.6 (see installation and download information in the JUnit 5 User Guide). The following Jar files are required:
junit-jupiter-api-5.6.2.jar(available from, for example, https://search.maven.org/artifact/org.junit.jupiter/junit-jupiter-api/5.6.2/jar).
junit-jupiter-engine-5.6.2.jar(available from, for example, https://search.maven.org/artifact/org.junit.jupiter/junit-jupiter-engine/5.6.2/jar).
junit-platform-commons-1.6.2.jar(available from, for example, https://search.maven.org/artifact/org.junit.platform/junit-platform-commons/1.6.2/jar).
junit-platform-engine-1.6.2.jar(available from, for example, https://search.maven.org/artifact/org.junit.platform/junit-platform-engine/1.6.2/jar).
junit-platform-launcher-1.6.2.jar(available from, for example, https://search.maven.org/artifact/org.junit.platform/junit-platform-launcher/1.6.2/jar).
These additional Jar files, which JUnit 5 depends on:
apiguardian-api-1.1.0.jar(available from, for example, https://search.maven.org/artifact/org.apiguardian/apiguardian-api/1.1.0/jar).
opentest4j-1.2.0.jar(available from, for example, https://search.maven.org/artifact/org.opentest4j/opentest4j/1.2.0/jar).
Javassist 3.27 or newer (
javassist.jar, available from, for example, https://search.maven.org/artifact/org.javassist/javassist/3.27.0-GA/bundle.
Protocol Buffers Java API 3.11.4 (
protobuf-java-3.11.4.jar, available from, for example, https://search.maven.org/artifact/com.google.protobuf/protobuf-java/3.11.4/bundle).
C3P0 0.9.5.5 or newer (both
c3p0-0.9.5.5.src.zip, available from, for example, https://search.maven.org/artifact/com.mchange/c3p0/0.9.5.5/jar or https://sourceforge.net/projects/c3p0/).
Simple Logging Facade API 1.7.30 or newer (
slf4j-api-1.7.30.jar, available from, for example, https://search.maven.org/artifact/org.slf4j/slf4j-api/1.7.30/jar or https://www.slf4j.org/download.html).
Java Hamcrest 2.2 or newer (hamcrest-2.2.jar, available from, for example, https://search.maven.org/artifact/org.hamcrest/hamcrest/2.2/jar).
To build MySQL Connector/J from source, follow these steps:
Make sure that you have JDK 1.8.x installed.
Obtain the sources for Connector/J by one of the following means:
Download the platform independent distribution archive (in
.zipformat) for Connector/J, which contains the sources, from the Connector/J Download page. Extract contents of the archive into a folder named, for example,
Download a source RPM package for Connector/J from Connector/J Download page and install it.
Check out the code from the source code repository for MySQL Connector/J located on GitHub at https://github.com/mysql/mysql-connector-j. The latest release of the Connector/J 8.0 series is on the
release/8.0branch; use the following command to check it out:
shell> git clone --branch release/8.0 https://github.com/mysql/mysql-connector-j.git
Under the current directory, the command creates a
mysql-connector-jsubdirectory , which contains the code you want.
Place all the required third-party libraries in a separate directory—for example,
Change your current working directory to the
mysql-connector-jdirectory created in step 2 above.
In the directory, create a file named
build.propertiesto indicate to Ant the locations of the root directories for your JDK 1.8.x installation, as well as the location of the extra libraries. The file should contain the following property settings, with the “
path_to_*” parts replaced by the appropriate file paths:
Alternatively, you can set the values of those properties through the Ant
Going from Connector/J 5.1 to 8.0, a number of Ant properties for building Connector/J have been renamed or removed; see Section 126.96.36.199, “Changes for Build Properties” for details.
Issue the following command to compile the driver and create a
.jarfile for Connector/J:
shell> ant dist
This creates a
builddirectory in the current directory, where all the build output goes. A directory is created under the
builddirectory, whose name includes the version number of the release you are building. That directory contains the sources, the compiled
.classfiles, and a
.jarfile for deployment.
For information on all the build targets, including those that create a fully packaged distribution, issue the following command:
shell> ant -projecthelp
Install the newly created
.jarfile for the JDBC driver as you would install a binary
.jarfile you download from MySQL by following the instructions given in Configuring the CLASSPATH or Configuring Connector/J for Application Servers.