Migrating from JDBC Driver 3.x to JDBC Driver 4.x

The JDBC Driver 4.x introduces several new features and improvements over the JDBC Driver 3.x. This topic provides an overview of the public API changes and new features and also provides information about how to migrate from JDBC Driver 3.x to JDBC Driver 4.x.

Public API overview

The Snowflake JDBC driver public API is located under the net.snowflake.client.api package (see API Reference). The changes to the public API between JDBC Driver 3.x and JDBC Driver 4.x are listed in the following table:

Package

Description

api.driver

JDBC driver registration and entry point

api.connection

Snowflake-specific connection and database metadata interfaces, stream transfer configuration

api.datasource

DataSource implementation for creating and managing connections

api.pooling

Connection pool data source for applications requiring pooled connections

api.resultset

Result set interfaces, field metadata, Snowflake data types, and async query status

api.auth

Authentication method definitions

api.loader

Bulk data loading API for high-volume ingestion with progress callbacks

Additionally, the driver includes classes in the net.snowflake.client.internal package that are not part of the public API. These classes are used internally by the driver and are not intended for use by application developers. Use the internal APIs at your own risk: They are subject to change without notice and without backward compatibility guarantees.

Code changes from JDBC Driver 3.x to JDBC Driver 4.x

Driver class name changes

The driver class name has changed.

Before (3.x)

After (4.x)

com.snowflake.client.jdbc.SnowflakeDriver

net.snowflake.client.api.driver.SnowflakeDriver

Data source creation changes

SnowflakeDataSource and SnowflakeConnectionPoolDataSource are now interfaces. Use factory classes instead of direct instantiation.

Component

Factory method

SnowflakeDataSource

SnowflakeDataSourceFactory.createDataSource()

SnowflakeConnectionPoolDataSource

SnowflakeConnectionPoolDataSourceFactory.createConnectionPoolDataSource()

Authentication type changes

The authentication type has changed from SNOWFLAKE to SNOWFLAKE_JDBC.

Before (3.x)

After (4.x)

externalbrowser

EXTERNAL_BROWSER

Other authentication types include the following:

  • SNOWFLAKE

  • OKTA

  • EXTERNAL_BROWSER

  • OAUTH

  • SNOWFLAKE_JWT

  • ID_TOKEN

  • USERNAME_PASSWORD_MFA

  • OAUTH_AUTHORIZATION_CODE

  • OAUTH_CLIENT_CREDENTIALS

  • PROGRAMMATIC_ACCESS_TOKEN

  • WORKLOAD_IDENTITY

Stream upload and download changes

The SnowflakeConnection interface simplified overloads for stream operations:

  • Upload:

    • uploadStream(stageName, destFileName, inputStream)

    • uploadStream(stageName, destFileName, inputStream, UploadStreamConfig)

    • UploadStreamConfig options: destPrefix, compressData (default: true)

  • Download:

    • downloadStream(stageName, sourceFileName)

    • downloadStream(stageName, sourceFileName, DownloadStreamConfig)

    • DownloadStreamConfig options: decompress (default: false)

SnowflakeType changes

The SnowflakeType enum has been removed. Type values remain the same, but the enum is no longer supported.

QueryStatus and SnowflakeAsyncResultSet changes

Version 4.0.0 made the following changes regarding queries and result sets:

  • The QueryStatus enum was replaced with DTO (previously known as QueryStatusV2). It carries the same data, but in a thread-safe manner. To retrieve query status, unwrap your result set to SnowflakeAsyncResultSet and call getStatus.

  • The getQueryErrorMessage on a result set is removed, but it can be retrieved directly from getErrorMessage on QueryStatus.

If you need an enum value representing the status, call getStatus on QueryStatus.