Package net.snowflake.client.jdbc
Class SnowflakeConnectionV1
- java.lang.Object
-
- net.snowflake.client.jdbc.SnowflakeConnectionV1
-
- All Implemented Interfaces:
AutoCloseable
,Connection
,Wrapper
,SnowflakeConnection
public class SnowflakeConnectionV1 extends Object implements Connection, SnowflakeConnection
Snowflake connection implementation
-
-
Field Summary
-
Fields inherited from interface java.sql.Connection
TRANSACTION_NONE, TRANSACTION_READ_COMMITTED, TRANSACTION_READ_UNCOMMITTED, TRANSACTION_REPEATABLE_READ, TRANSACTION_SERIALIZABLE
-
-
Constructor Summary
Constructors Constructor Description SnowflakeConnectionV1(String url, Properties info)
A connection will establish a session token from snowflakeSnowflakeConnectionV1(String url, Properties info, boolean fakeConnection)
SnowflakeConnectionV1(SFConnectionHandler sfConnectionHandler)
Instantiates a SnowflakeConnectionV1 with the passed-in SnowflakeConnectionImpl.SnowflakeConnectionV1(SFConnectionHandler sfConnectionHandler, String url, Properties info)
Instantiates a SnowflakeConnectionV1 with the passed-in SnowflakeConnectionImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
abort(Executor executor)
void
clearWarnings()
void
close()
Close the connectionvoid
commit()
void
compressAndUploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName)
Deprecated.Array
createArrayOf(String typeName, Object[] elements)
Blob
createBlob()
Clob
createClob()
NClob
createNClob()
ResultSet
createResultSet(String queryID)
Get an instance of a ResultSet objectSQLXML
createSQLXML()
Statement
createStatement()
Create a statementStatement
createStatement(int resultSetType, int resultSetConcurrency)
Statement
createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
Struct
createStruct(String typeName, Object[] attributes)
InputStream
downloadStream(String stageName, String sourceFileName, boolean decompress)
Download file from the given stage and return an input streamboolean
getAutoCommit()
String
getCatalog()
String[]
getChildQueryIds(String queryID)
Return an array of child query ID for the given query ID.Properties
getClientInfo()
String
getClientInfo(String name)
SFConnectionHandler
getHandler()
Returns the SnowflakeConnectionImpl from the connection object.int
getHoldability()
DatabaseMetaData
getMetaData()
Return the database metadataint
getNetworkTimeout()
String
getSchema()
String
getSessionID()
Return unique session ID from current session generated by making connectionSFBaseSession
getSFBaseSession()
SFSession
getSfSession()
boolean
getShowStatementParameters()
int
getTransactionIsolation()
Map<String,Class<?>>
getTypeMap()
SQLWarning
getWarnings()
boolean
isClosed()
boolean
isReadOnly()
boolean
isValid(int timeout)
boolean
isWrapperFor(Class<?> iface)
String
nativeSQL(String sql)
CallableStatement
prepareCall(String sql)
CallableStatement
prepareCall(String sql, boolean skipParsing)
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency)
CallableStatement
prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatement
prepareStatement(String sql)
PreparedStatement
prepareStatement(String sql, boolean skipParsing)
PreparedStatement
prepareStatement(String sql, int autoGeneratedKeys)
PreparedStatement
prepareStatement(String sql, int[] columnIndexes)
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
PreparedStatement
prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
PreparedStatement
prepareStatement(String sql, String[] columnNames)
void
releaseSavepoint(Savepoint savepoint)
List<DriverPropertyInfo>
returnMissingProperties()
void
rollback()
void
rollback(Savepoint savepoint)
void
setAutoCommit(boolean isAutoCommit)
void
setCatalog(String catalog)
void
setClientInfo(String name, String value)
void
setClientInfo(Properties properties)
void
setHoldability(int holdability)
void
setInjectedDelay(int delay)
void
setInjectFileUploadFailure(String fileToFail)
void
setNetworkTimeout(Executor executor, int milliseconds)
void
setReadOnly(boolean readOnly)
Savepoint
setSavepoint()
Savepoint
setSavepoint(String name)
void
setSchema(String schema)
void
setTransactionIsolation(int level)
Sets the transaction isolation level.void
setTypeMap(Map<String,Class<?>> map)
<T> T
unwrap(Class<T> iface)
void
uploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName, boolean compressData)
Method to compress data from a stream and upload it at a stage location.void
uploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName, long streamSize)
Deprecated.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.sql.Connection
beginRequest, endRequest, setShardingKey, setShardingKey, setShardingKeyIfValid, setShardingKeyIfValid
-
-
-
-
Constructor Detail
-
SnowflakeConnectionV1
public SnowflakeConnectionV1(SFConnectionHandler sfConnectionHandler) throws SQLException
Instantiates a SnowflakeConnectionV1 with the passed-in SnowflakeConnectionImpl.- Parameters:
sfConnectionHandler
- The SnowflakeConnectionImpl.- Throws:
SQLException
-
SnowflakeConnectionV1
public SnowflakeConnectionV1(SFConnectionHandler sfConnectionHandler, String url, Properties info) throws SQLException
Instantiates a SnowflakeConnectionV1 with the passed-in SnowflakeConnectionImpl.- Parameters:
sfConnectionHandler
- The SnowflakeConnectionImpl.- Throws:
SQLException
-
SnowflakeConnectionV1
public SnowflakeConnectionV1(String url, Properties info) throws SQLException
A connection will establish a session token from snowflake- Parameters:
url
- server url used to create snowflake connectioninfo
- properties about the snowflake connection- Throws:
SQLException
- if failed to create a snowflake connection i.e. username or password not specified
-
SnowflakeConnectionV1
public SnowflakeConnectionV1(String url, Properties info, boolean fakeConnection) throws SQLException
- Throws:
SQLException
-
-
Method Detail
-
returnMissingProperties
public List<DriverPropertyInfo> returnMissingProperties()
-
createStatement
public Statement createStatement() throws SQLException
Create a statement- Specified by:
createStatement
in interfaceConnection
- Returns:
- statement statement object
- Throws:
SQLException
- if failed to create a snowflake statement
-
createResultSet
public ResultSet createResultSet(String queryID) throws SQLException
Get an instance of a ResultSet object- Specified by:
createResultSet
in interfaceSnowflakeConnection
- Parameters:
queryID
-- Returns:
- Throws:
SQLException
-
getChildQueryIds
public String[] getChildQueryIds(String queryID) throws SQLException
Return an array of child query ID for the given query ID.If the given query ID is for a multiple statements query, it returns an array of its child statements, otherwise, it returns an array to include the given query ID.
- Parameters:
queryID
- The given query ID- Returns:
- An array of child query IDs
- Throws:
SQLException
- If the query is running or the corresponding query is FAILED.
-
close
public void close() throws SQLException
Close the connection- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceConnection
- Throws:
SQLException
- failed to close the connection
-
getSessionID
public String getSessionID() throws SQLException
Description copied from interface:SnowflakeConnection
Return unique session ID from current session generated by making connection- Specified by:
getSessionID
in interfaceSnowflakeConnection
- Returns:
- a unique alphanumeric value representing current session ID
- Throws:
SQLException
-
isClosed
public boolean isClosed() throws SQLException
- Specified by:
isClosed
in interfaceConnection
- Throws:
SQLException
-
getMetaData
public DatabaseMetaData getMetaData() throws SQLException
Return the database metadata- Specified by:
getMetaData
in interfaceConnection
- Returns:
- Database metadata
- Throws:
SQLException
- if any database error occurs
-
prepareCall
public CallableStatement prepareCall(String sql) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, boolean skipParsing) throws SQLException
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCall
in interfaceConnection
- Throws:
SQLException
-
nativeSQL
public String nativeSQL(String sql) throws SQLException
- Specified by:
nativeSQL
in interfaceConnection
- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException
- Specified by:
getAutoCommit
in interfaceConnection
- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean isAutoCommit) throws SQLException
- Specified by:
setAutoCommit
in interfaceConnection
- Throws:
SQLException
-
commit
public void commit() throws SQLException
- Specified by:
commit
in interfaceConnection
- Throws:
SQLException
-
rollback
public void rollback() throws SQLException
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollback
in interfaceConnection
- Throws:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException
- Specified by:
isReadOnly
in interfaceConnection
- Throws:
SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException
- Specified by:
setReadOnly
in interfaceConnection
- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalog
in interfaceConnection
- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
- Specified by:
setCatalog
in interfaceConnection
- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException
- Specified by:
getTransactionIsolation
in interfaceConnection
- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws SQLException
Sets the transaction isolation level.- Specified by:
setTransactionIsolation
in interfaceConnection
- Parameters:
level
- transaction level: TRANSACTION_NONE or TRANSACTION_READ_COMMITTED- Throws:
SQLException
- if any SQL error occurs
-
getWarnings
public SQLWarning getWarnings() throws SQLException
- Specified by:
getWarnings
in interfaceConnection
- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException
- Specified by:
clearWarnings
in interfaceConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatement
in interfaceConnection
- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, boolean skipParsing) throws SQLException
- Throws:
SQLException
-
getTypeMap
public Map<String,Class<?>> getTypeMap() throws SQLException
- Specified by:
getTypeMap
in interfaceConnection
- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
- Specified by:
setTypeMap
in interfaceConnection
- Throws:
SQLException
-
getHoldability
public int getHoldability() throws SQLException
- Specified by:
getHoldability
in interfaceConnection
- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException
- Specified by:
setHoldability
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepoint
in interfaceConnection
- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepoint
in interfaceConnection
- Throws:
SQLException
-
createBlob
public Blob createBlob() throws SQLException
- Specified by:
createBlob
in interfaceConnection
- Throws:
SQLException
-
createClob
public Clob createClob() throws SQLException
- Specified by:
createClob
in interfaceConnection
- Throws:
SQLException
-
createNClob
public NClob createNClob() throws SQLException
- Specified by:
createNClob
in interfaceConnection
- Throws:
SQLException
-
createSQLXML
public SQLXML createSQLXML() throws SQLException
- Specified by:
createSQLXML
in interfaceConnection
- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException
- Specified by:
isValid
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfo
in interfaceConnection
- Throws:
SQLClientInfoException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfo
in interfaceConnection
- Throws:
SQLException
-
createArrayOf
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- Specified by:
createArrayOf
in interfaceConnection
- Throws:
SQLException
-
createStruct
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- Specified by:
createStruct
in interfaceConnection
- Throws:
SQLException
-
getSchema
public String getSchema() throws SQLException
- Specified by:
getSchema
in interfaceConnection
- Throws:
SQLException
-
setSchema
public void setSchema(String schema) throws SQLException
- Specified by:
setSchema
in interfaceConnection
- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abort
in interfaceConnection
- Throws:
SQLException
-
setNetworkTimeout
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- Specified by:
setNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws SQLException
- Specified by:
getNetworkTimeout
in interfaceConnection
- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperFor
in interfaceWrapper
- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrap
in interfaceWrapper
- Throws:
SQLException
-
getHandler
public SFConnectionHandler getHandler()
Description copied from interface:SnowflakeConnection
Returns the SnowflakeConnectionImpl from the connection object.- Specified by:
getHandler
in interfaceSnowflakeConnection
-
uploadStream
@Deprecated public void uploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName, long streamSize) throws SQLException
Deprecated.Method to put data from a stream at a stage location. The data will be uploaded as one file. No splitting is done in this method.Stream size must match the total size of data in the input stream unless compressData parameter is set to true.
caller is responsible for passing the correct size for the data in the stream and releasing the inputStream after the method is called.
Note this method is deprecated since streamSize is not required now. Keep the function signature for backward compatibility
- Parameters:
stageName
- stage name: e.g. ~ or table name or stage namedestPrefix
- path prefix under which the data should be uploaded on the stageinputStream
- input stream from which the data will be uploadeddestFileName
- destination file name to usestreamSize
- data size in the stream- Throws:
SQLException
- failed to put data from a stream at stage
-
uploadStream
public void uploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName, boolean compressData) throws SQLException
Method to compress data from a stream and upload it at a stage location. The data will be uploaded as one file. No splitting is done in this method.caller is responsible for releasing the inputStream after the method is called.
- Specified by:
uploadStream
in interfaceSnowflakeConnection
- Parameters:
stageName
- stage name: e.g. ~ or table name or stage namedestPrefix
- path prefix under which the data should be uploaded on the stageinputStream
- input stream from which the data will be uploadeddestFileName
- destination file name to usecompressData
- compress data or not before uploading stream- Throws:
SQLException
- failed to compress and put data from a stream at stage
-
compressAndUploadStream
@Deprecated public void compressAndUploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName) throws SQLException
Deprecated.Method to compress data from a stream and upload it at a stage location. The data will be uploaded as one file. No splitting is done in this method.caller is responsible for releasing the inputStream after the method is called.
This method is deprecated
- Parameters:
stageName
- stage name: e.g. ~ or table name or stage namedestPrefix
- path prefix under which the data should be uploaded on the stageinputStream
- input stream from which the data will be uploadeddestFileName
- destination file name to use- Throws:
SQLException
- failed to compress and put data from a stream at stage
-
downloadStream
public InputStream downloadStream(String stageName, String sourceFileName, boolean decompress) throws SQLException
Download file from the given stage and return an input stream- Specified by:
downloadStream
in interfaceSnowflakeConnection
- Parameters:
stageName
- stage namesourceFileName
- file path in stagedecompress
- true if file compressed- Returns:
- an input stream
- Throws:
SnowflakeSQLException
- if any SQL error occurs.SnowflakeSQLException
- if any SQL error occurs.SQLException
-
setInjectedDelay
public void setInjectedDelay(int delay) throws SQLException
- Throws:
SQLException
-
setInjectFileUploadFailure
public void setInjectFileUploadFailure(String fileToFail) throws SQLException
- Throws:
SQLException
-
getSFBaseSession
public SFBaseSession getSFBaseSession()
-
getSfSession
public SFSession getSfSession() throws SnowflakeSQLException
- Throws:
SnowflakeSQLException
-
getShowStatementParameters
public boolean getShowStatementParameters()
-
-