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
`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
`void` `clearSqlWarnings()`
`void` `close()` Close the connection
`void` `closeTelemetryClient()`
`protected int` `getAndIncrementSequenceId()`
`String` `getArrayBindStage()`
`int` `getArrayBindStageThreshold()`
`boolean` `getAutoCommit()`
`Properties` `getClientInfo()`
`String` `getClientInfo(String name)`
`String` `getDatabase()`
`int` `getDatabaseMajorVersion()`
`int` `getDatabaseMinorVersion()`
`String` `getDatabaseVersion()`
`boolean` `getEnableCombineDescribe()`
`protected int` `getHttpClientConnectionTimeout()`
`protected int` `getHttpClientSocketTimeout()`
`String` `getIdToken()`
`int` `getInjectClientPause()`
`String` `getInjectFileUploadFailure()`
`int` `getInjectSocketTimeout()`
`boolean` `getMetadataRequestUseConnectionCtx()`
`protected int` `getNetworkTimeoutInMilli()`
`String` `getNewClientForUpdate()`
`Integer` `getQueryTimeout()`
`String` `getRole()`
`boolean` `getRsColumnCaseInsensitive()`
`String` `getSchema()`
`protected String` `getServerUrl()`
`String` `getServiceName()` Gets the service name provided from GS.
`String` `getSessionToken()` get session token
`Object` `getSFSessionProperty(String propertyName)`
`List<SFException>` `getSqlWarnings()`
`Telemetry` `getTelemetryClient()`
`SnowflakeType` `getTimestampMappedType()`
`String` `getUrl()`
`String` `getUser()`
`String` `getWarehouse()`
`protected void` `heartbeat()` Send heartbeat for the session
`boolean` `isClientTelemetryEnabled()`
`boolean` `isClosed()`
`boolean` `isEnableHeartbeat()`
`boolean` `isExecuteReturnCountForDML()`
`boolean` `isJdbcTreatDecimalAsInt()`
`boolean` `isStoreTemporaryCredential()`
`void` `open()` Open a new database session
`void` `setArrayBindStage(String arrayBindStage)`
`void` `setArrayBindStageThreshold(int arrayBindStageThreshold)`
`void` `setAutoCommit(boolean autoCommit)`
`void` `setClientInfo(Properties properties)`
`void` `setClientInfo(String name, String value)`
`void` `setClientTelemetryEnabled(boolean clientTelemetryEnabled)`
`void` `setDatabase(String database)`
`void` `setEnableCombineDescribe(boolean enable)`
`void` `setEnableHeartbeat(boolean enableHeartbeat)`
`void` `setExecuteReturnCountForDML(boolean executeReturnCountForDML)`
`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` `setRole(String role)`
`void` `setRsColumnCaseInsensitive(boolean rsColumnCaseInsensitive)`
`void` `setSchema(String schema)`
`void` `setServiceName(String serviceName)` Sets the service name provided from GS.
`void` `setStoreTemporaryCredential(boolean storeTemporaryCredential)`
`void` `setTimestampMappedType(SnowflakeType timestampMappedType)`
`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

### Constructor Detail

#### SFSession

    public SFSession()

### Method Detail

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

#### getServerUrl

    protected String getServerUrl()

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

#### getNewClientForUpdate

    public String getNewClientForUpdate()

#### getDatabaseVersion

    public String getDatabaseVersion()

#### getDatabaseMajorVersion

    public int getDatabaseMajorVersion()

#### getDatabaseMinorVersion

    public int getDatabaseMinorVersion()

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

#### setClientInfo

    public void setClientInfo(Properties properties)
                       throws SQLClientInfoException

Throws:
  `SQLClientInfoException`

#### setClientInfo

    public void setClientInfo(String name,
                              String value)
                       throws SQLClientInfoException

Throws:
  `SQLClientInfoException`

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

    protected 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()

#### setExecuteReturnCountForDML

    public void setExecuteReturnCountForDML(boolean executeReturnCountForDML)

#### isExecuteReturnCountForDML

    public boolean isExecuteReturnCountForDML()

#### isEnableHeartbeat

    public boolean isEnableHeartbeat()

#### setEnableHeartbeat

    public void setEnableHeartbeat(boolean enableHeartbeat)

#### getAutoCommit

    public boolean getAutoCommit()

#### setAutoCommit

    public void setAutoCommit(boolean autoCommit)

#### setRsColumnCaseInsensitive

    public void setRsColumnCaseInsensitive(boolean rsColumnCaseInsensitive)

#### getRsColumnCaseInsensitive

    public boolean getRsColumnCaseInsensitive()

#### 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)

#### getMetadataRequestUseConnectionCtx

    public boolean getMetadataRequestUseConnectionCtx()

#### 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()

#### 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()

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