Table of Contents
There are two ways to install the Connector/J. One method is through a binary distribution and the other is through Source Distribution. Binary Distribution offers the easiest download solution but if you want to customize the process, you will need to use source distribution.
Installing Connector/J from a Binary Distribution
The various download packages for Connector/J (binary distribution) can be found on the following web page: https://dev.mysql.com/downloads/connector/j/. Two of the most common types of packages are:
- Using Platform-independent Archives: Two types of files, namely .tar.gz or .zip files can be found from this package. These files facilitate the installation of Connector/J on any platform. With the help of an appropriate graphical or command-line utility, extract the JAR archive from the above-mentioned files.
- Using Packages for Software Package Management Systems on Linux Platforms: RPM and Debian Packages can be used to install Connector/J on Linux-run machines.
Configuring the CLASSPATH
If you want to add a Connector/J driver to your classpath, you can use one of the following commands:
# Bourne-compatible shell (sh, ksh, bash, zsh):
shell> export CLASSPATH=/path/mysql-connector-java-ver.jar:$CLASSPATH
# C shell (csh, tcsh):
shell> setenv CLASSPATH /path/mysql-connector-java-ver.jar:$CLASSPATH
Installing from Source
If you want to install Connector/J from source, you need to have one of the following source files or third-party libraries already installed in your computer:
- A Git Client
- Apache Ant version 1.10.6 or newer
- JDK 1.8.x
- Junit 5.6
- Javassist 3.27
- Protocol Buffers Java API 3.11.4
- C3P) 0.9.5.5
- Simple Logging Facade API 1.7.30
- Java Hamcrest 2.2
Steps to Install from Source
- Download the required archive (.tar.gz or .zip format).
- Download a package from the following link: https://dev.mysql.com/downloads/connector/j/.
- Use the following command:
shell> git clone –branch release/8.0 https://github.com/mysql/mysql-connector-j.git. This will create a subdirectory under the current directory.
- Move all third-party libraries to a different directory.
- Rename the directory according to step 2.
- Inside the directory, make a new file called build.properties.
- Finally compile the driver: shell> ant dist.