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:
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
.zip archive to a suitable location.
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.
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
-cp when starting the JVM.
For example, on Linux platforms, add the Connector/J driver to
CLASSPATH using one of the following
forms, depending on your command shell:
# 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
You can also set the
variable in a profile file, either locally for a user within the
or other login file, or globally by editing the global
For Windows platforms, you set the environment variable through the System Control Panel.
Remember to also add the locations of the third-party libraries required for using Connector/J to CLASSPATH.
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
Chapter 8, Connection Pooling with Connector/J,
Section 9.3, “Configuring Load Balancing with Connector/J”,
Section 9.5, “Advanced Load-balancing and Failover Configuration”.
However, the authoritative source for JDBC connection pool
configuration information is the documentation for your own
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
MysqlConnectionPoolDataSource classes in
com.mysql.cj.jdbc package, if your J2EE
application server supports or requires them. The
javax.sql.XADataSource interface is
implemented using the
which supports XA distributed transactions. The various
MysqlDataSource classes support the
following parameters (through standard set mutators):