net.snowflake.client.core

## Class SFSession

- java.lang.Object
- - net.snowflake.client.core.SFSession

    public class SFSession
    extends Object

Snowflake session implementation

### Field Summary

Fields
`protected Set<String>` `activeAsyncQueries`
`static String` `SF_HEADER_AUTHORIZATION`
`static String` `SF_HEADER_SNOWFLAKE_AUTHTYPE`
`static String` `SF_HEADER_TOKEN_TAG`
`static String` `SF_QUERY_REQUEST_ID`

### Constructor Summary

Constructors
Constructor and Description
`SFSession()`

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `addProperty(SFSessionProperty sfSessionProperty, Object propertyValue)`
`void` `addProperty(String propertyName, Object propertyValue)` Add a property If a property is known for connection, add it to connection properties If not, add it as a dynamic session parameters
`List<DriverPropertyInfo>` `checkProperties()`
`void` `clearSqlWarnings()`
`void` `close()` Close the connection
`void` `closeTelemetryClient()`
`boolean` `containProperty(String key)`
`protected int` `getAndIncrementSequenceId()`
`String` `getArrayBindStage()`
`int` `getArrayBindStageThreshold()`
`boolean` `getAutoCommit()`
`Properties` `getClientInfo()`
`String` `getClientInfo(String name)`
`int` `getClientMemoryLimit()`
`int` `getClientPrefetchThreads()`
`int` `getClientResultChunkSize()`
`int` `getConservativeMemoryAdjustStep()`
`String` `getDatabase()`
`int` `getDatabaseMajorVersion()`
`int` `getDatabaseMinorVersion()`
`String` `getDatabaseVersion()`
`boolean` `getEnableCombineDescribe()`
`boolean` `getFormatDateWithTimezone()`
`long` `getHeartbeatFrequency()`
`protected int` `getHttpClientConnectionTimeout()`
`protected int` `getHttpClientSocketTimeout()`
`String` `getIdToken()`
`int` `getInjectClientPause()`
`String` `getInjectFileUploadFailure()`
`int` `getInjectSocketTimeout()`
`int` `getInjectWaitInPut()`
`boolean` `getMetadataRequestUseConnectionCtx()`
`boolean` `getMetadataRequestUseSessionDatabase()`
`String` `getMfaToken()`
`int` `getNetworkTimeoutInMilli()`
`OCSPMode` `getOCSPMode()`
`boolean` `getPreparedStatementLogging()`
`QueryStatus` `getQueryStatus(String queryID)`
`Integer` `getQueryTimeout()`
`String` `getRole()`
`String` `getSchema()`
`protected String` `getServerUrl()`
`String` `getServiceName()` Gets the service name provided from GS.
`String` `getSessionId()`
`String` `getSessionToken()` get session token
`Object` `getSFSessionProperty(String propertyName)`
`SnowflakeConnectString` `getSnowflakeConnectionString()`
`List<SFException>` `getSqlWarnings()`
`Telemetry` `getTelemetryClient()`
`SnowflakeType` `getTimestampMappedType()`
`boolean` `getTreatNTZAsUTC()`
`String` `getUrl()`
`String` `getUser()`
`boolean` `getUseSessionTimezone()`
`String` `getWarehouse()`
`protected void` `heartbeat()` Send heartbeat for the session
`boolean` `isClientTelemetryEnabled()`
`boolean` `isClosed()`
`boolean` `isConservativeMemoryUsageEnabled()`
`boolean` `isEnableHeartbeat()`
`boolean` `isJdbcTreatDecimalAsInt()`
`boolean` `isResultColumnCaseInsensitive()`
`boolean` `isSafeToClose()` Function that checks if the active session can be closed when the connection is closed.
`boolean` `isSfSQLMode()`
`boolean` `isStoreTemporaryCredential()`
`boolean` `isStringQuoted()`
`boolean` `isValidateDefaultParameters()`
`void` `open()` Open a new database session
`void` `setArrayBindStage(String arrayBindStage)`
`void` `setArrayBindStageThreshold(int arrayBindStageThreshold)`
`void` `setAutoCommit(boolean autoCommit)`
`void` `setClientMemoryLimit(int clientMemoryLimit)`
`void` `setClientPrefetchThreads(int clientPrefetchThreads)`
`void` `setClientResultChunkSize(int clientResultChunkSize)`
`void` `setClientTelemetryEnabled(boolean clientTelemetryEnabled)`
`void` `setConservativeMemoryAdjustStep(int step)`
`void` `setDatabase(String database)`
`void` `setEnableCombineDescribe(boolean enable)`
`void` `setEnableConservativeMemoryUsage(boolean value)`
`void` `setEnableHeartbeat(boolean enableHeartbeat)`
`void` `setFormatDateWithTimezone(boolean useTimezone)`
`void` `setHeartbeatFrequency(int frequency)`
`void` `setInjectClientPause(int injectClientPause)`
`void` `setInjectedDelay(int delay)`
`void` `setInjectFileUploadFailure(String fileToFail)`
`void` `setInjectSocketTimeout(int injectSocketTimeout)`
`void` `setJdbcTreatDecimalAsInt(boolean jdbcTreatDecimalAsInt)`
`void` `setMetadataRequestUseConnectionCtx(boolean enabled)`
`void` `setMetadataRequestUseSessionDatabase(boolean enabled)`
`void` `setPreparedStatementLogging(boolean value)`
`void` `setResultColumnCaseInsensitive(boolean resultColumnCaseInsensitive)`
`void` `setRole(String role)`
`void` `setSchema(String schema)`
`void` `setServiceName(String serviceName)` Sets the service name provided from GS.
`void` `setSfSQLMode(boolean sfSQLMode)`
`void` `setSnowflakeConnectionString(SnowflakeConnectString connStr)`
`void` `setStoreTemporaryCredential(boolean storeTemporaryCredential)`
`void` `setTimestampMappedType(SnowflakeType timestampMappedType)`
`void` `setTreatNTZAsUTC(boolean enabled)`
`void` `setUseSessionTimezone(boolean useSessionTimezone)`
`void` `setValidateDefaultParameters(boolean v)`
`void` `setWarehouse(String warehouse)`
`protected void` `startHeartbeatForThisSession()` Start heartbeat for this session
`protected void` `stopHeartbeatForThisSession()` Stop heartbeat for this session

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### SF_QUERY_REQUEST_ID

    public static final String SF_QUERY_REQUEST_ID

See Also:
  Constant Field Values

#### SF_HEADER_AUTHORIZATION

    public static final String SF_HEADER_AUTHORIZATION

See Also:
  Constant Field Values

#### SF_HEADER_SNOWFLAKE_AUTHTYPE

    public static final String SF_HEADER_SNOWFLAKE_AUTHTYPE

See Also:
  Constant Field Values

#### SF_HEADER_TOKEN_TAG

    public static final String SF_HEADER_TOKEN_TAG

See Also:
  Constant Field Values

#### activeAsyncQueries

    protected Set<String> activeAsyncQueries

### Constructor Detail

#### SFSession

    public SFSession()

### Method Detail

#### isSafeToClose

    public boolean isSafeToClose()

Function that checks if the active session can be closed when the connection is closed. If there are active asynchronous queries running, the session should stay open even if the connection closes so that the queries can finish running.

Returns:
  true if it is safe to close this session, false if not

#### getQueryStatus

    public QueryStatus getQueryStatus(String queryID)
                               throws SQLException

Parameters:
  `queryID` - query ID of the query whose status is being investigated
Returns:
  enum of type QueryStatus indicating the query's status
Throws:
  `SQLException`

#### addProperty

    public void addProperty(SFSessionProperty sfSessionProperty,
                            Object propertyValue)
                     throws SFException

Throws:
  `SFException`

#### addProperty

    public void addProperty(String propertyName,
                            Object propertyValue)
                     throws SFException

Add a property If a property is known for connection, add it to connection properties If not, add it as a dynamic session parameters

Make sure a property is not added more than once and the number of properties does not exceed limit.

Parameters:
  `propertyName` - property name
  `propertyValue` - property value
Throws:
  `SFException` - exception raised from Snowflake components

#### containProperty

    public boolean containProperty(String key)

#### getServerUrl

    protected String getServerUrl()

#### isStringQuoted

    public boolean isStringQuoted()

#### open

    public void open()
              throws SFException,
                     SnowflakeSQLException

Open a new database session

Throws:
  `SFException` - this is a runtime exception
  `SnowflakeSQLException` - exception raised from Snowflake components

#### getOCSPMode

    public OCSPMode getOCSPMode()

#### checkProperties

    public List<DriverPropertyInfo> checkProperties()

#### getDatabaseVersion

    public String getDatabaseVersion()

#### getDatabaseMajorVersion

    public int getDatabaseMajorVersion()

#### getDatabaseMinorVersion

    public int getDatabaseMinorVersion()

#### getSessionId

    public String getSessionId()

#### getSessionToken

    public String getSessionToken()

get session token

Returns:
  session token

#### close

    public void close()
               throws SFException,
                      SnowflakeSQLException

Close the connection

Throws:
  `SnowflakeSQLException` - if failed to close the connection
  `SFException` - if failed to close the connection

#### startHeartbeatForThisSession

    protected void startHeartbeatForThisSession()

Start heartbeat for this session

#### stopHeartbeatForThisSession

    protected void stopHeartbeatForThisSession()

Stop heartbeat for this session

#### heartbeat

    protected void heartbeat()
                      throws SFException,
                             SQLException

Send heartbeat for the session

Throws:
  `SFException` - exception raised from Snowflake
  `SQLException` - exception raised from SQL generic layers

#### getClientInfo

    public Properties getClientInfo()

#### getClientInfo

    public String getClientInfo(String name)

#### getSFSessionProperty

    public Object getSFSessionProperty(String propertyName)

#### setInjectedDelay

    public void setInjectedDelay(int delay)

#### getInjectSocketTimeout

    public int getInjectSocketTimeout()

#### setInjectSocketTimeout

    public void setInjectSocketTimeout(int injectSocketTimeout)

#### setInjectFileUploadFailure

    public void setInjectFileUploadFailure(String fileToFail)

#### getInjectFileUploadFailure

    public String getInjectFileUploadFailure()

#### getNetworkTimeoutInMilli

    public int getNetworkTimeoutInMilli()

#### isClosed

    public boolean isClosed()

#### getInjectClientPause

    public int getInjectClientPause()

#### setInjectClientPause

    public void setInjectClientPause(int injectClientPause)

#### getHttpClientConnectionTimeout

    protected int getHttpClientConnectionTimeout()

#### getHttpClientSocketTimeout

    protected int getHttpClientSocketTimeout()

#### getAndIncrementSequenceId

    protected int getAndIncrementSequenceId()

#### setSfSQLMode

    public void setSfSQLMode(boolean sfSQLMode)

#### isSfSQLMode

    public boolean isSfSQLMode()

#### isEnableHeartbeat

    public boolean isEnableHeartbeat()

#### setEnableHeartbeat

    public void setEnableHeartbeat(boolean enableHeartbeat)

#### setHeartbeatFrequency

    public void setHeartbeatFrequency(int frequency)

#### getHeartbeatFrequency

    public long getHeartbeatFrequency()

#### getAutoCommit

    public boolean getAutoCommit()

#### setAutoCommit

    public void setAutoCommit(boolean autoCommit)

#### getPreparedStatementLogging

    public boolean getPreparedStatementLogging()

#### setPreparedStatementLogging

    public void setPreparedStatementLogging(boolean value)

#### setResultColumnCaseInsensitive

    public void setResultColumnCaseInsensitive(boolean resultColumnCaseInsensitive)

#### isResultColumnCaseInsensitive

    public boolean isResultColumnCaseInsensitive()

#### getDatabase

    public String getDatabase()

#### setDatabase

    public void setDatabase(String database)

#### getSchema

    public String getSchema()

#### setSchema

    public void setSchema(String schema)

#### getRole

    public String getRole()

#### setRole

    public void setRole(String role)

#### getWarehouse

    public String getWarehouse()

#### setWarehouse

    public void setWarehouse(String warehouse)

#### setMetadataRequestUseConnectionCtx

    public void setMetadataRequestUseConnectionCtx(boolean enabled)

#### setMetadataRequestUseSessionDatabase

    public void setMetadataRequestUseSessionDatabase(boolean enabled)

#### getMetadataRequestUseConnectionCtx

    public boolean getMetadataRequestUseConnectionCtx()

#### setTreatNTZAsUTC

    public void setTreatNTZAsUTC(boolean enabled)

#### setFormatDateWithTimezone

    public void setFormatDateWithTimezone(boolean useTimezone)

#### getFormatDateWithTimezone

    public boolean getFormatDateWithTimezone()

#### setUseSessionTimezone

    public void setUseSessionTimezone(boolean useSessionTimezone)

#### getUseSessionTimezone

    public boolean getUseSessionTimezone()

#### getTreatNTZAsUTC

    public boolean getTreatNTZAsUTC()

#### getMetadataRequestUseSessionDatabase

    public boolean getMetadataRequestUseSessionDatabase()

#### getTimestampMappedType

    public SnowflakeType getTimestampMappedType()

#### setTimestampMappedType

    public void setTimestampMappedType(SnowflakeType timestampMappedType)

#### isJdbcTreatDecimalAsInt

    public boolean isJdbcTreatDecimalAsInt()

#### setJdbcTreatDecimalAsInt

    public void setJdbcTreatDecimalAsInt(boolean jdbcTreatDecimalAsInt)

#### setEnableCombineDescribe

    public void setEnableCombineDescribe(boolean enable)

#### getEnableCombineDescribe

    public boolean getEnableCombineDescribe()

#### getQueryTimeout

    public Integer getQueryTimeout()

#### getUser

    public String getUser()

#### getUrl

    public String getUrl()

#### getInjectWaitInPut

    public int getInjectWaitInPut()

#### getSqlWarnings

    public List<SFException> getSqlWarnings()

#### clearSqlWarnings

    public void clearSqlWarnings()

#### getTelemetryClient

    public Telemetry getTelemetryClient()

#### closeTelemetryClient

    public void closeTelemetryClient()

#### isClientTelemetryEnabled

    public boolean isClientTelemetryEnabled()

#### setClientTelemetryEnabled

    public void setClientTelemetryEnabled(boolean clientTelemetryEnabled)

#### getArrayBindStageThreshold

    public int getArrayBindStageThreshold()

#### setArrayBindStageThreshold

    public void setArrayBindStageThreshold(int arrayBindStageThreshold)

#### getArrayBindStage

    public String getArrayBindStage()

#### setArrayBindStage

    public void setArrayBindStage(String arrayBindStage)

#### getIdToken

    public String getIdToken()

#### getMfaToken

    public String getMfaToken()

#### isStoreTemporaryCredential

    public boolean isStoreTemporaryCredential()

#### setStoreTemporaryCredential

    public void setStoreTemporaryCredential(boolean storeTemporaryCredential)

#### setServiceName

    public void setServiceName(String serviceName)

Sets the service name provided from GS.

Parameters:
  `serviceName` - service name

#### getServiceName

    public String getServiceName()

Gets the service name provided from GS.

Returns:
  the service name

#### isConservativeMemoryUsageEnabled

    public boolean isConservativeMemoryUsageEnabled()

#### setEnableConservativeMemoryUsage

    public void setEnableConservativeMemoryUsage(boolean value)

#### setConservativeMemoryAdjustStep

    public void setConservativeMemoryAdjustStep(int step)

#### getConservativeMemoryAdjustStep

    public int getConservativeMemoryAdjustStep()

#### setClientMemoryLimit

    public void setClientMemoryLimit(int clientMemoryLimit)

#### getClientMemoryLimit

    public int getClientMemoryLimit()

#### setClientResultChunkSize

    public void setClientResultChunkSize(int clientResultChunkSize)

#### getClientResultChunkSize

    public int getClientResultChunkSize()

#### setClientPrefetchThreads

    public void setClientPrefetchThreads(int clientPrefetchThreads)

#### getClientPrefetchThreads

    public int getClientPrefetchThreads()

#### isValidateDefaultParameters

    public boolean isValidateDefaultParameters()

#### setValidateDefaultParameters

    public void setValidateDefaultParameters(boolean v)

#### setSnowflakeConnectionString

    public void setSnowflakeConnectionString(SnowflakeConnectString connStr)

#### getSnowflakeConnectionString

    public SnowflakeConnectString getSnowflakeConnectionString()