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 |
|---|---|
|
|
|
|
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.