Menu
Amazon Redshift
Management Guide (API Version 2012-12-01)

Configure a JDBC Connection With Apache Maven

Apache Maven is a software project management and comprehension tool. The AWS SDK for Java supports Apache Maven projects. For more information, see Using the SDK with Apache Maven.

If you use Apache Maven, you can configure and build your projects to use an Amazon Redshift JDBC driver to connect to your Amazon Redshift cluster. To do this, you need to add the JDBC driver as a dependency in your project’s pom.xml file. Follow the steps in this section if you use Maven to build your project and want to use a JDBC connection.

Configuring the JDBC Driver as a Maven Dependency

To configure the JDBC Driver as a Maven dependency

  1. Add the following repository to the repositories section of your pom.xml file.

    Note

    The URL in the following code will return an error if used in a browser. The URL is intended to be used only within the context of a Maven project.

    <repositories>
        <repository>
          <id>redshift</id>
          <url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
        </repository>
    </repositories>
  2. Declare the version of the driver you want to use in the dependencies section of your pom.xml file.

    Amazon Redshift offers drivers for tools that are compatible with either the JDBC 4.2 API, JDBC 4.1 API, or JDBC 4.0 API. For information about the functionality supported by these drivers, go to the Amazon Redshift JDBC Driver Release Notes.

    Add a dependency for the driver from the following list.

    Note

    For version 1.2.1.1001 and later, you can use either the generic driver class name com.amazon.redshift.jdbc.Driver or the version-specific class name listed with the driver in the list following; for example com.amazon.redshift.jdbc42.Driver. For releases prior to 1.2.1001, only version specific class names are supported.

    • JDBC 4.2–compatible driver:

      <dependency>
         <groupId>com.amazon.redshift</groupId>
         <artifactId>redshift-jdbc42</artifactId>
         <version>1.2.1.1001</version>
      </dependency>

      The class name for this driver is com.amazon.redshift.jdbc42.Driver.

    • JDBC 4.1–compatible driver:

      <dependency>
        <groupId>com.amazon.redshift</groupId>
        <artifactId>redshift-jdbc41</artifactId>
        <version>1.2.1.1001</version>
      </dependency>

      The class name for this driver is com.amazon.redshift.jdbc41.Driver.

    • JDBC 4.0–compatible driver:

      <dependency>
        <groupId>com.amazon.redshift</groupId>
        <artifactId>redshift-jdbc4</artifactId>
        <version>1.2.1.1001</version>
      </dependency>

      The class name for this driver is com.amazon.redshift.jdbc4.Driver.

  3. Download and review the Amazon Redshift JDBC Driver License Agreement.

If you need to distribute these drivers to your customers or other third parties, please send email to redshift-pm@amazon.com to arrange an appropriate license.

Previous JDBC Driver Versions

Add a previous version of the Amazon Redshift JDBC driver to your project only if your tool requires a specific version of the driver. For information about the functionality supported in previous versions of the drivers, download Amazon Redshift JDBC Driver Release Notes.

These are previous JDBC 4.2–compatible drivers:

  • JDBC42-1.1.17.1017

    <dependency>
      <groupId>com.amazon.redshift</groupId>
      <artifactId>redshift-jdbc42</artifactId>
      <version>1.1.17.1017</version>
    </dependency> 

These are previous JDBC 4.1–compatible drivers:

  • JDBC41-1.1.17.1017

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.17.1017</version>
    </dependency>
  • JDBC41-1.1.10.1010

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.10.1010</version>
    </dependency>
  • JDBC41-1.1.9.1009

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.9.1009</version>
    </dependency>
  • JDBC41-1.1.7.1007

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.7.1007</version>
    </dependency>
  • JDBC41-1.1.6.1006

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.6.1006</version>
    </dependency>
  • JDBC41-1.1.2.0002

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.2.0002</version>
    </dependency>
  • JDBC41-1.1.1.0001

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.1.0001</version>
    </dependency>
  • JDBC41-1.1.0.0000

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc41</artifactId>
       <version>1.1.0.0000</version>
    </dependency>

These are previous JDBC 4.0–compatible drivers:

  • JDBC4-1.1.17.1017

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.17.1017</version>
    </dependency>
  • JDBC4-1.1.10.1010

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.10.1010</version>
    </dependency>
  • JDBC4-1.1.9.1009

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.9.1009</version>
    </dependency>
  • JDBC4-1.1.7.1007

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.7.1007</version>
    </dependency>
  • JDBC4-1.1.6.1006

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.6.1006</version>
    </dependency>
  • JDBC4-1.1.2.0002

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.2.0002</version>
    </dependency>
  • JDBC4-1.1.1.0001

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.1.0001</version>
    </dependency>
  • JDBC4-1.1.0.0000

    <dependency>
       <groupId>com.amazon.redshift</groupId>
       <artifactId>redshift-jdbc4</artifactId>
       <version>1.1.0.0000</version>
    </dependency>

Upgrading the Driver to the Latest Version

To upgrade or change the Amazon Redshift JDBC driver to the latest version, modify the version section of the dependency to the latest version of the driver and then clean your project with the Maven Clean Plugin, as shown following.

mvn clean