Gradle/Maven dependency for Redshift JDBC driver

The first thing to realize is that amazon documentation tells you to load the v4 version of the driver JAR file. If you downloaded the driver you got a v4X version of the driver so your code should be:

Class.forName("com.amazon.redshift.jdbc41.Driver");

NOT

Class.forName("com.amazon.redshift.jdbc4.Driver");

Note the addition of the version number in the first example!

The driver jar is here:

http://docs.aws.amazon.com/redshift/latest/mgmt/configure-jdbc-connection.html

Amazon does not publish to Maven (Come on Amazon WTF?) so you have to import the jar you download. The Maven import command (for JDBC) looks like this:

mvn install:install-file -Dfile=./RedshiftJDBC41-1.1.10.1010.jar -DgroupId=com.amazon -DartifactId=redshift.jdbc41 -Dversion=1.1.10.1010 -Dpackaging=jar -DgeneratePom=true

The Maven dependency looks like this (Note that the artificatID and Version should be what you gave it in the mvn command above. If the driver has been updated, then the mvn command and the dependency fields have to change):

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

Redshift JDBC drivers are now available on maven repo. Look at http://docs.aws.amazon.com/redshift/latest/mgmt/configure-jdbc-connection-with-maven.html

If the link doesn't work, navigate to Querying a Database -> Connecting to a Cluster Using SQL Client Tools -> Configuring Connections in Amazon Redshift -> Configuring a JDBC Connection

Add the redshift repository

<repositories>
    <repository>
      <id>redshift</id>
      <url>http://redshift-maven-repository.s3-website-us-east-1.amazonaws.com/release</url>
    </repository>
</repositories>

And then add the dependency, like

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

But there are many variants on the driver, so you should visit the page to read more and pick the one you need.