Installing Connector/J

Introduction

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

  1. Download the required archive (.tar.gz or .zip format).
  2. Download a package from the following link: https://dev.mysql.com/downloads/connector/j/.
  3. 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.
  4. Move all third-party libraries to a different directory.
  5. Rename the directory according to step 2.
  6. Inside the directory, make a new file called build.properties.
  7. Finally compile the driver: shell> ant dist.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.