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 |
|---|---|
JDBC driver registration and entry point |
|
Snowflake-specific connection and database metadata interfaces, stream transfer configuration |
|
DataSource implementation for creating and managing connections |
|
Connection pool data source for applications requiring pooled connections |
|
Result set interfaces, field metadata, Snowflake data types, and async query status |
|
Authentication method definitions |
|
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) |
|---|---|
|
|
Data source creation changes¶
SnowflakeDataSource and SnowflakeConnectionPoolDataSource are now interfaces. Use factory classes instead of direct instantiation.
Component |
Factory method |
|---|---|
|
|
|
|
Authentication type changes¶
The authentication type has changed from SNOWFLAKE to SNOWFLAKE_JDBC.
Before (3.x) |
After (4.x) |
|---|---|
|
|
Other authentication types include the following:
SNOWFLAKEOKTAEXTERNAL_BROWSEROAUTHSNOWFLAKE_JWTID_TOKENUSERNAME_PASSWORD_MFAOAUTH_AUTHORIZATION_CODEOAUTH_CLIENT_CREDENTIALSPROGRAMMATIC_ACCESS_TOKENWORKLOAD_IDENTITY
Stream upload and download changes¶
The SnowflakeConnection interface simplified overloads for stream operations:
Upload:
uploadStream(stageName, destFileName, inputStream)uploadStream(stageName, destFileName, inputStream, UploadStreamConfig)UploadStreamConfigoptions:destPrefix,compressData(default:true)
Download:
downloadStream(stageName, sourceFileName)downloadStream(stageName, sourceFileName, DownloadStreamConfig)DownloadStreamConfigoptions: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
QueryStatusenum was replaced with DTO (previously known asQueryStatusV2). It carries the same data, but in a thread-safe manner. To retrieve query status, unwrap your result set toSnowflakeAsyncResultSetand callgetStatus.The
getQueryErrorMessageon a result set is removed, but it can be retrieved directly fromgetErrorMessageonQueryStatus.
If you need an enum value representing the status, call getStatus on QueryStatus.