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 voidabort(Executor executor)voidclearWarnings()voidclose()Close the connectionvoidcommit()voidcompressAndUploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName)Deprecated.ArraycreateArrayOf(String typeName, Object[] elements)BlobcreateBlob()ClobcreateClob()NClobcreateNClob()ResultSetcreateResultSet(String queryID)Get an instance of a ResultSet objectSQLXMLcreateSQLXML()StatementcreateStatement()Create a statementStatementcreateStatement(int resultSetType, int resultSetConcurrency)StatementcreateStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)StructcreateStruct(String typeName, Object[] attributes)InputStreamdownloadStream(String stageName, String sourceFileName, boolean decompress)Download file from the given stage and return an input streambooleangetAutoCommit()StringgetCatalog()String[]getChildQueryIds(String queryID)Return an array of child query ID for the given query ID.PropertiesgetClientInfo()StringgetClientInfo(String name)SFConnectionHandlergetHandler()Returns the SnowflakeConnectionImpl from the connection object.intgetHoldability()DatabaseMetaDatagetMetaData()Return the database metadataintgetNetworkTimeout()StringgetSchema()StringgetSessionID()Return unique session ID from current session generated by making connectionSFBaseSessiongetSFBaseSession()SFSessiongetSfSession()booleangetShowStatementParameters()intgetTransactionIsolation()Map<String,Class<?>>getTypeMap()SQLWarninggetWarnings()booleanisClosed()booleanisReadOnly()booleanisValid(int timeout)booleanisWrapperFor(Class<?> iface)StringnativeSQL(String sql)CallableStatementprepareCall(String sql)CallableStatementprepareCall(String sql, boolean skipParsing)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency)CallableStatementprepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql)PreparedStatementprepareStatement(String sql, boolean skipParsing)PreparedStatementprepareStatement(String sql, int autoGeneratedKeys)PreparedStatementprepareStatement(String sql, int[] columnIndexes)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency)PreparedStatementprepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)PreparedStatementprepareStatement(String sql, String[] columnNames)voidreleaseSavepoint(Savepoint savepoint)List<DriverPropertyInfo>returnMissingProperties()voidrollback()voidrollback(Savepoint savepoint)voidsetAutoCommit(boolean isAutoCommit)voidsetCatalog(String catalog)voidsetClientInfo(String name, String value)voidsetClientInfo(Properties properties)voidsetHoldability(int holdability)voidsetInjectedDelay(int delay)voidsetInjectFileUploadFailure(String fileToFail)voidsetNetworkTimeout(Executor executor, int milliseconds)voidsetReadOnly(boolean readOnly)SavepointsetSavepoint()SavepointsetSavepoint(String name)voidsetSchema(String schema)voidsetTransactionIsolation(int level)Sets the transaction isolation level.voidsetTypeMap(Map<String,Class<?>> map)<T> Tunwrap(Class<T> iface)voiduploadStream(String stageName, String destPrefix, InputStream inputStream, String destFileName, boolean compressData)Method to compress data from a stream and upload it at a stage location.voiduploadStream(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- if failed to instantiate a SnowflakeConnectionV1.
-
SnowflakeConnectionV1
public SnowflakeConnectionV1(SFConnectionHandler sfConnectionHandler, String url, Properties info) throws SQLException
Instantiates a SnowflakeConnectionV1 with the passed-in SnowflakeConnectionImpl.- Parameters:
sfConnectionHandler- The SnowflakeConnectionImpl.url- The URL string.info- Connection properties.- Throws:
SQLException- if failed to instantiate connection.
-
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:
createStatementin 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:
createResultSetin interfaceSnowflakeConnection- Parameters:
queryID- the query ID- Returns:
- ResultSet
- Throws:
SQLException- if connection is closed
-
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 SQLExceptionClose the connection- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceConnection- Throws:
SQLException- failed to close the connection
-
getSessionID
public String getSessionID() throws SQLException
Description copied from interface:SnowflakeConnectionReturn unique session ID from current session generated by making connection- Specified by:
getSessionIDin interfaceSnowflakeConnection- Returns:
- a unique alphanumeric value representing current session ID
- Throws:
SQLException- if an error occurs
-
isClosed
public boolean isClosed() throws SQLException- Specified by:
isClosedin interfaceConnection- Throws:
SQLException
-
getMetaData
public DatabaseMetaData getMetaData() throws SQLException
Return the database metadata- Specified by:
getMetaDatain interfaceConnection- Returns:
- Database metadata
- Throws:
SQLException- if any database error occurs
-
prepareCall
public CallableStatement prepareCall(String sql) throws SQLException
- Specified by:
prepareCallin 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:
prepareCallin interfaceConnection- Throws:
SQLException
-
prepareCall
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareCallin interfaceConnection- Throws:
SQLException
-
nativeSQL
public String nativeSQL(String sql) throws SQLException
- Specified by:
nativeSQLin interfaceConnection- Throws:
SQLException
-
getAutoCommit
public boolean getAutoCommit() throws SQLException- Specified by:
getAutoCommitin interfaceConnection- Throws:
SQLException
-
setAutoCommit
public void setAutoCommit(boolean isAutoCommit) throws SQLException- Specified by:
setAutoCommitin interfaceConnection- Throws:
SQLException
-
commit
public void commit() throws SQLException- Specified by:
commitin interfaceConnection- Throws:
SQLException
-
rollback
public void rollback() throws SQLException- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
rollback
public void rollback(Savepoint savepoint) throws SQLException
- Specified by:
rollbackin interfaceConnection- Throws:
SQLException
-
isReadOnly
public boolean isReadOnly() throws SQLException- Specified by:
isReadOnlyin interfaceConnection- Throws:
SQLException
-
setReadOnly
public void setReadOnly(boolean readOnly) throws SQLException- Specified by:
setReadOnlyin interfaceConnection- Throws:
SQLException
-
getCatalog
public String getCatalog() throws SQLException
- Specified by:
getCatalogin interfaceConnection- Throws:
SQLException
-
setCatalog
public void setCatalog(String catalog) throws SQLException
- Specified by:
setCatalogin interfaceConnection- Throws:
SQLException
-
getTransactionIsolation
public int getTransactionIsolation() throws SQLException- Specified by:
getTransactionIsolationin interfaceConnection- Throws:
SQLException
-
setTransactionIsolation
public void setTransactionIsolation(int level) throws SQLExceptionSets the transaction isolation level.- Specified by:
setTransactionIsolationin 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:
getWarningsin interfaceConnection- Throws:
SQLException
-
clearWarnings
public void clearWarnings() throws SQLException- Specified by:
clearWarningsin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
createStatement
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
createStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
- Specified by:
prepareStatementin interfaceConnection- Throws:
SQLException
-
prepareStatement
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException
- Specified by:
prepareStatementin 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:
getTypeMapin interfaceConnection- Throws:
SQLException
-
setTypeMap
public void setTypeMap(Map<String,Class<?>> map) throws SQLException
- Specified by:
setTypeMapin interfaceConnection- Throws:
SQLException
-
getHoldability
public int getHoldability() throws SQLException- Specified by:
getHoldabilityin interfaceConnection- Throws:
SQLException
-
setHoldability
public void setHoldability(int holdability) throws SQLException- Specified by:
setHoldabilityin interfaceConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint() throws SQLException
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
setSavepoint
public Savepoint setSavepoint(String name) throws SQLException
- Specified by:
setSavepointin interfaceConnection- Throws:
SQLException
-
releaseSavepoint
public void releaseSavepoint(Savepoint savepoint) throws SQLException
- Specified by:
releaseSavepointin interfaceConnection- Throws:
SQLException
-
createBlob
public Blob createBlob() throws SQLException
- Specified by:
createBlobin interfaceConnection- Throws:
SQLException
-
createClob
public Clob createClob() throws SQLException
- Specified by:
createClobin interfaceConnection- Throws:
SQLException
-
createNClob
public NClob createNClob() throws SQLException
- Specified by:
createNClobin interfaceConnection- Throws:
SQLException
-
createSQLXML
public SQLXML createSQLXML() throws SQLException
- Specified by:
createSQLXMLin interfaceConnection- Throws:
SQLException
-
isValid
public boolean isValid(int timeout) throws SQLException- Specified by:
isValidin interfaceConnection- Throws:
SQLException
-
setClientInfo
public void setClientInfo(String name, String value) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
getClientInfo
public Properties getClientInfo() throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
setClientInfo
public void setClientInfo(Properties properties) throws SQLClientInfoException
- Specified by:
setClientInfoin interfaceConnection- Throws:
SQLClientInfoException
-
getClientInfo
public String getClientInfo(String name) throws SQLException
- Specified by:
getClientInfoin interfaceConnection- Throws:
SQLException
-
createArrayOf
public Array createArrayOf(String typeName, Object[] elements) throws SQLException
- Specified by:
createArrayOfin interfaceConnection- Throws:
SQLException
-
createStruct
public Struct createStruct(String typeName, Object[] attributes) throws SQLException
- Specified by:
createStructin interfaceConnection- Throws:
SQLException
-
getSchema
public String getSchema() throws SQLException
- Specified by:
getSchemain interfaceConnection- Throws:
SQLException
-
setSchema
public void setSchema(String schema) throws SQLException
- Specified by:
setSchemain interfaceConnection- Throws:
SQLException
-
abort
public void abort(Executor executor) throws SQLException
- Specified by:
abortin interfaceConnection- Throws:
SQLException
-
setNetworkTimeout
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
- Specified by:
setNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
getNetworkTimeout
public int getNetworkTimeout() throws SQLException- Specified by:
getNetworkTimeoutin interfaceConnection- Throws:
SQLException
-
isWrapperFor
public boolean isWrapperFor(Class<?> iface) throws SQLException
- Specified by:
isWrapperForin interfaceWrapper- Throws:
SQLException
-
unwrap
public <T> T unwrap(Class<T> iface) throws SQLException
- Specified by:
unwrapin interfaceWrapper- Throws:
SQLException
-
getHandler
public SFConnectionHandler getHandler()
Description copied from interface:SnowflakeConnectionReturns the SnowflakeConnectionImpl from the connection object.- Specified by:
getHandlerin interfaceSnowflakeConnection- Returns:
- SFConnectionHandler
-
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:
uploadStreamin 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:
downloadStreamin 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()
-
-