Documentation Home
Connectors and APIs Manual
Download this Manual
PDF (US Ltr) - 4.1Mb
PDF (A4) - 4.1Mb


Connectors and APIs Manual  /  ...  /  Installing Connector/J from a Binary Distribution

3.3.1 Installing Connector/J from a Binary Distribution

Obtaining and Using the Binary Distribution Packages

Different types of binary distribution packages for Connector/J are available from the Connector/J Download page. The following explains how to use each type of the packages to install Connector/J.

Using Platform-independent Archives: .tar.gz or .zip archives are available for installing Connector/J on any platform. Using the appropriate graphical or command-line utility (for example, tar for the .tar.gz archive and WinZip for the .zip archive), extract the JAR archive from the .tar.gz or .zip archive to a suitable location.

Note

Because there are potentially long file names in the distribution, the Connector/J archives use the GNU Tar archive format. Use GNU Tar or a compatible application to unpack the .tar.gz variant of the distribution.

Using Packages for Software Package Management Systems on Linux Platforms: RPM and Debian packages are available for installing Connector/J on a number of Linux distributions like Oracle Linux, Debian, Ubuntu, SUSE, and so on. Install these packages using your system's software package management system.

On Windows Platforms: You cannot install Connector/J on Windows platforms using the MySQL Installer for Windows. Notice that there are also no stand-alone Windows installer files (.msi) for installing Connector/J. Use the platform-independent archives instead for installations on Windows platforms.

Configuring the CLASSPATH

Once mysql-connector-j-version.jar has been extracted from the binary distribution package to the right place, finish installing the driver by placing the JAR archive in your Java classpath, either by adding its full file path to your CLASSPATH environment variable, or by directly specifying the file path with the command line switch -cp when starting the JVM.

For example, on Linux platforms, add the Connector/J driver to your CLASSPATH using one of the following forms, depending on your command shell:

# Bourne-compatible shell (sh, ksh, bash, zsh):
$> export CLASSPATH=/path/mysql-connector-j-ver.jar:$CLASSPATH
# C shell (csh, tcsh):
$> setenv CLASSPATH /path/mysql-connector-j-ver.jar:$CLASSPATH

You can also set the CLASSPATH environment variable in a profile file, either locally for a user within the user's .profile, .login, or other login file, or globally by editing the global /etc/profile file.

For Windows platforms, you set the environment variable through the System Control Panel.

Important

Remember to also add the locations of the third-party libraries required for using Connector/J to CLASSPATH.

Configuring Connector/J for Application Servers

To use MySQL Connector/J with an application server such as GlassFish or Tomcat, read your vendor's documentation for information on how to configure third-party class libraries, as most application servers ignore the CLASSPATH environment variable. For configuration examples for some J2EE application servers, see Section 3.7, “Connection Pooling with Connector/J”, Section 3.8.3, “Configuring Load Balancing with Connector/J”, and Section 3.8.5, “Advanced Load-balancing and Failover Configuration”. However, the authoritative source for JDBC connection pool configuration information is the documentation for your own application server.

If you are developing servlets or JSPs and your application server is J2EE-compliant, you can put the driver's .jar file in the WEB-INF/lib subdirectory of your web application, as this is a standard location for third-party class libraries in J2EE web applications. You can also use the MysqlDataSource or MysqlConnectionPoolDataSource classes in the com.mysql.cj.jdbc package, if your J2EE application server supports or requires them. The javax.sql.XADataSource interface is implemented using the com.mysql.cj.jdbc.MysqlXADataSource class, which supports XA distributed transactions. The various MysqlDataSource classes support the following parameters (through standard set mutators):

  • user

  • password

  • serverName

  • databaseName

  • port