Downloading / integrating the JDBC Driver

The JDBC driver (snowflake-jdbc) is provided as a JAR file, available as an artifact in Maven for download or for integration directly into your Java-based projects. Additionally, you can also download the following types of drivers from Maven:

  • FIPS-compliant fat jar named snowflake-jdbc-fips.

  • Thin jar named snowflake-jdbc-thin.

Source code for the additional types is the same, but their dependencies’ configurations are different, as follows:

  • The FIPS-compliant fat jar does not embed the FIPS Bouncy Castle dependencies, so you need to provide them during runtime.

  • The thin jar embeds only some dependencies, so you need to provide the other dependencies according to the pom file declaration.

All JAR types are released together with the same version number.

Before downloading or integrating the driver, you should verify the version of the driver you are currently using. To verify your driver version, connect to Snowflake through a client application that uses the driver and check the driver version. If the application supports executing SQL queries, you can do this by calling the CURRENT_CLIENT function.

Requirements

For a list of the operating systems supported by Snowflake clients, see Operating system support.

Downloading the desired type of driver

To download the driver, follow the steps for the desired driver type.

Download a standard driver

To download the standard driver:

  1. Go to the Maven Central Repository for the standard driver.

  2. Select the directory for the version that you need.

    The most recent version (3.21.0) is not always at the end of the list. Versions are listed alphabetically, not numerically. For example, 3.10.x comes after 3.1.x, not after 3.9.x.

  3. Download the appropriate snowflake-jdbc-#.#.#.jar file:

    Note

    You can verify the JDBC driver version by entering the following command:

    java -jar snowflake-jdbc-#.#.#.jar --version, where #.#.# matches the version numbers in the downloaded file name.

  4. Optional: To verify the driver package signature, download the corresponding snowflake-jdbc-#.#.#.jar.asc file.

Download a FIPS-compliant driver

To download the FIPS-compliant driver:

  1. Go to the Maven Central Repository for the FIPS-compliant driver.

  2. Select the directory for the version that you need.

    The most recent version (3.21.0) is not always at the end of the list. Versions are listed alphabetically, not numerically. For example, 3.10.x comes after 3.1.x, not after 3.9.x.

  3. Download the appropriate snowflake-jdbc-fips-#.#.#.jar file:

    Note

    You can verify the JDBC driver version by entering the following command:

    java -jar snowflake-jdbc-fips-#.#.#.jar --version, where #.#.# matches the version numbers in the downloaded file name.

  4. Optionally, you can verify the driver package signature, download the corresponding snowflake-jdbc-fips-#.#.#.jar.asc file.

Download a thin-jar driver

To download the thin-jar driver:

  1. Go to the Maven Central Repository for the thin-jar driver.

  2. Select the directory for the version that you need.

    The most recent version (3.21.0) is not always at the end of the list. Versions are listed alphabetically, not numerically. For example, 3.10.x comes after 3.1.x, not after 3.9.x.

  3. Download the appropriate snowflake-jdbc-thin-#.#.#.jar file:

    Note

    You can verify the JDBC driver version by entering the following command:

    java -jar snowflake-jdbc-thin-#.#.#.jar --version, where #.#.# matches the version numbers in the downloaded file name.

  4. Optionally, you can verify the driver package signature, download the corresponding snowflake-jdbc-thin-#.#.#.jar.asc file.

Optional: Verify the driver package signature

To verify the JDBC driver package signature:

  1. From the public keyserver, download and import the Snowflake GPG public key for the version of the JDBC driver that you are using:

    • For version 3.19.1 and higher:

      $ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 5A125630709DD64B
    • For version 3.13.23 through 3.19.0:

      $ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 630D9F3CAB551AF3
    • For version 3.12.13 through 3.13.22:

      $ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 37C7086698CB005C
    • For version 3.6.26 through 3.12.12:

      $ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys EC218558EABB25A1
    • For version 3.6.25 and lower:

      $ gpg --keyserver hkp://keyserver.ubuntu.com --recv-keys 93DB296A69BE019A

    Note

    If this command fails with the following error:

    gpg: keyserver receive failed: Server indicated a failure
    
    Copy

    then specify that you want to use port 80 for the keyserver:

    gpg --keyserver hkp://keyserver.ubuntu.com:80  ...
    
    Copy
  2. Run the gpg --verify command to verify the signature of the package.

    For the --verify command-line flag, specify the .asc file that you downloaded earlier as the signature file and the JAR file as the file containing the signed data.

    For example:

    $ gpg --verify snowflake-jdbc-3.21.0.jar.asc snowflake-jdbc-3.21.0.jar
    gpg: Signature made Wed 22 Feb 2017 04:31:58 PM UTC using RSA key ID <gpg_key_id>
    gpg: Good signature from "Snowflake Computing <snowflake_gpg@snowflake.net>"

    Specify the correct version numbers for the JDBC driver package you are verifying. Version 3.21.0 is used in this example for illustration purposes only. The latest available version of the driver may be higher.

    Note

    Verifying the signature produces a warning similar to the following:

    gpg: Signature made Mon 24 Sep 2018 03:03:45 AM UTC using RSA key ID <gpg_key_id>
    gpg: Good signature from "Snowflake Computing <snowflake_gpg@snowflake.net>" unknown
    gpg: WARNING: This key is not certified with a trusted signature!
    gpg: There is no indication that the signature belongs to the owner.
    
    Copy

    To avoid the warning, you can grant the Snowflake GPG public key implicit trust.

  3. Your local environment can contain multiple GPG keys; however, for security reasons, Snowflake periodically rotates the public GPG key. As a best practice, we recommend deleting the existing public key after confirming that the latest key works with the latest signed package:

    $ gpg --delete-key "Snowflake Computing"
    
    Copy

Integrate the driver into a maven project

To integrate the driver into a Maven project:

  • Add the driver as a dependency to your pom.xml file.

For example:

  • Standard driver

    <dependencies>
      ...
      <dependency>
        <groupId>net.snowflake</groupId>
        <artifactId>snowflake-jdbc</artifactId>
        <version>3.21.0</version>
      </dependency>
      ...
    </dependencies>
  • FIPS-compliant driver

    <dependencies>
      ...
      <dependency>
        <groupId>net.snowflake</groupId>
        <artifactId>snowflake-jdbc-fips</artifactId>
        <version>3.21.0</version>
      </dependency>
      ...
    </dependencies>
  • Thin-jar driver

    <dependencies>
      ...
      <dependency>
        <groupId>net.snowflake</groupId>
        <artifactId>snowflake-jdbc-thin</artifactId>
        <version>3.21.0</version>
      </dependency>
      ...
    </dependencies>

where the <version> tag specifies the version of the driver you want to integrate. Note that version 3.21.0 is used in this example for illustration purposes only. A later version of the driver might be available.

The developer notes are hosted along with the source code on GitHub (https://github.com/snowflakedb/snowflake-jdbc).

Add the JNA classes to your classpath

Connection caching for browser-based SSO and token caching for multi-factor authentication (MFA) require the use of the Java Native Access (JNA) classes (https://github.com/java-native-access/jna/blob/master/README.md) to save data securely to the filesystem.

As of version 3.12.18 of the JDBC Driver, the JNA classes are no longer packaged in the JDBC Driver JAR file. In the JDBC Driver pom.xml file, the dependencies on these classes are marked as optional.

If you need to use connection caching or token caching, you must add the following libraries to your classpath:

  • For Mac and Linux:

    • JNA

  • For Windows:

    • JNA

    • JNA Platform

The pom.xml file for the JDBC Driver specifies the version of the JNA classes that have been tested with the JDBC Driver. Snowflake recommends using this version (or the same major version) of the JNA classes.

Note

For systems that use the aarch64 architecture (e.g. the Apple M1 chip), use version 5.7.0 or later of the JNA libraries. (JNA versions prior to v5.7.0 are not compatible with Windows and macOS systems that run on aarch64.)

Language: English