3.4 Installing from the Development Source Tree

Caution

Read this section only if you are interested in helping us test our new code. To just get MySQL Connector/J up and running on your system, use a standard binary release distribution.

To install MySQL Connector/J from the development source tree, make sure that you have the following software on your system:

To check out and compile a specific branch of MySQL Connector/J, follow these steps:

  1. Check out the latest code from the branch that you want with one of the following commands.

    The source code repository for MySQL Connector/J is located on Launchpad at https://code.launchpad.net/connectorj. To check out the latest development branch, use:

    shell> bzr branch lp:connectorj
    

    This creates a connectorj subdirectory in the current directory that contains the latest sources for the requested branch.

    To check out the latest 5.1 code, use:

    shell> bzr branch lp:connectorj/5.1
    

    This creates a 5.1 subdirectory in the current directory containing the latest 5.1 code.

  2. To build Connector/J 5.1, make sure that you have both JDK 1.6.x AND JDK 1.5.x installed. You need both JDKs because Connector/J 5.1 supports both JDBC 3.0 (which has existed prior to JDK 1.6.x) and JDBC 4.0. Set your JAVA_HOME environment variable to the path to the JDK 1.5.x installation.

  3. Place the required ant-contrib.jar file (in exactly that name, without the version number in it; rename the jar file if needed) and junit.jar file in a separate directory—for example, /home/username/ant-extralibs.

  4. In the same directory for extra libraries described in the last step, create a directory named hibernate4, and put under it all the jar files you can find under the /lib/required/ folder in the Hibernate ORM 4.1.2 Final release bundle.

  5. Change your current working directory to either the connectorj or 5.1 directory, depending on which branch you intend to build.

  6. In the directory, create a file named build.properties to indicate to Ant the locations of the Javac and rt.jar of your JDK 1.6.x, 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 filepaths:

    com.mysql.jdbc.java6.javac=path_to_javac_1.6/javac
    com.mysql.jdbc.java6.rtjar=path_to_rt.jar_under_jdk_1.6/rt.jar
    com.mysql.jdbc.extra.libs=path_to_folder_for_extra_libraries
    

    Alternatively, you can set the values of those properties through the Ant -D options.

  7. Issue the following command to compile the driver and create a .jar file suitable for installation:

    shell> ant dist
    

    This creates a build directory in the current directory, where all build output will go. A directory is created in the build directory that includes the version number of the sources you are building from. This directory contains the sources, compiled .class files, and a .jar file suitable for deployment. For other possible targets, including those that create a fully packaged distribution, issue the following command:

    shell> ant -projecthelp
    
  8. A newly created .jar file containing the JDBC driver will be placed in the directory build/mysql-connector-java-version.

    Install the newly created JDBC driver as you would install a binary .jar file you download from MySQL by following the instructions given in Section 3.2, “Installing the Driver and Configuring the CLASSPATH.

A package containing both the binary and source code for Connector/J 5.1 can also be found at the following location: Connector/J 5.1 Download