Class SFBaseSession

  • Direct Known Subclasses:
    SFSession

    public abstract class SFBaseSession
    extends Object
    Snowflake session implementation base. The methods and fields contained within this class are setters and getters for shared session properties, i.e., those that may be set via connection time, in properties, as well as those that may be parsed from response headers from Snowflake (i.e., session parameters).

    New connection properties and session parameters can be added here, as SFBaseSession contains the logic for storing, setting, and getting these session properties.

    For logic that is specific to a particular type of Session, four methods need to be implemented:

    open(), for establishing a connection. close(), for closing a connection. isSafeToClose(), for checking whether the connection can be closed. checkProperties(), invoked at connection time to verify if the requisite properties are set; and if not, returns a list of missing properties raiseError(), which handles exceptions that may be raised in the session isTelemetryEnabled(), which signals whether to enable client telemetry

    • Field Detail

      • heartbeatFrequency

        protected int heartbeatFrequency
      • MEMORY_LIMIT_UNSET

        public static long MEMORY_LIMIT_UNSET
    • Method Detail

      • setMemoryLimitForTesting

        public void setMemoryLimitForTesting​(long memLimit)
      • getMemoryLimitForTesting

        public long getMemoryLimitForTesting()
      • getClientInfo

        public Properties getClientInfo()
        Part of the JDBC API, where client applications may fetch a Map of Properties to set various attributes. This is not used internally by any driver component, but should be maintained by the Session object.
      • setCommonParameters

        public void setCommonParameters​(Map<String,​Object> parameters)
      • getClientInfo

        public String getClientInfo​(String name)
        Gets the Property associated with the key 'name' in the ClientInfo map.
        Parameters:
        name - The key from which to fetch the Property.
      • getSessionId

        public String getSessionId()
        Returns a unique id for this session.
      • setSessionId

        public void setSessionId​(String sessionId)
        Sets the session-id attribute in this session.
        Parameters:
        sessionId - The session id as a string.
      • isSfSQLMode

        public boolean isSfSQLMode()
      • setSfSQLMode

        public void setSfSQLMode​(boolean sfSQLMode)
      • getDatabaseVersion

        public String getDatabaseVersion()
      • setDatabaseVersion

        public void setDatabaseVersion​(String databaseVersion)
      • getDatabaseMajorVersion

        public int getDatabaseMajorVersion()
      • setDatabaseMajorVersion

        public void setDatabaseMajorVersion​(int databaseMajorVersion)
      • getDatabaseMinorVersion

        public int getDatabaseMinorVersion()
      • setDatabaseMinorVersion

        public void setDatabaseMinorVersion​(int databaseMinorVersion)
      • getPreparedStatementLogging

        public boolean getPreparedStatementLogging()
      • setPreparedStatementLogging

        public void setPreparedStatementLogging​(boolean value)
      • getInjectFileUploadFailure

        public String getInjectFileUploadFailure()
      • setInjectFileUploadFailure

        public void setInjectFileUploadFailure​(String fileToFail)
      • getTimestampMappedType

        public SnowflakeType getTimestampMappedType()
      • setTimestampMappedType

        public void setTimestampMappedType​(SnowflakeType timestampMappedType)
      • isResultColumnCaseInsensitive

        public boolean isResultColumnCaseInsensitive()
      • setResultColumnCaseInsensitive

        public void setResultColumnCaseInsensitive​(boolean resultColumnCaseInsensitive)
      • isJdbcTreatDecimalAsInt

        public boolean isJdbcTreatDecimalAsInt()
      • setJdbcTreatDecimalAsInt

        public void setJdbcTreatDecimalAsInt​(boolean jdbcTreatDecimalAsInt)
      • getServerUrl

        public String getServerUrl()
      • isStringQuoted

        public boolean isStringQuoted()
      • addProperty

        public void addProperty​(SFSessionProperty sfSessionProperty,
                                Object propertyValue)
                         throws SFException
        Wrapper function for the other addProperty(String, Object) method that takes an SFSessionProperty instead of a String key.
        Parameters:
        sfSessionProperty - The property for which to set the value.
        propertyValue - The value to set for the property.
        Throws:
        SFException - If the value already exists for the given key (should only be set once), or if the value is invalid.
      • addProperty

        public void addProperty​(String propertyName,
                                Object propertyValue)
                         throws SFException
        Adds a connection property to the connection-properties map. Connection properties are those that are defined in SFSessionProperty. They are set typically through instantiation of the Session.
        Parameters:
        propertyName - The name of the property, as a string. Recognized ones are defined in the SFSessionProperty enum.
        propertyValue - The value to set for this key.
        Throws:
        SFException - If the value already exists for the given key (should only be set once), or if the value is invalid.
      • unsetInvalidProxyHostAndPort

        public void unsetInvalidProxyHostAndPort()
      • getOCSPMode

        public OCSPMode getOCSPMode()
      • getQueryTimeout

        public Integer getQueryTimeout()
      • getUser

        public String getUser()
      • getUrl

        public String getUrl()
      • getInjectWaitInPut

        public int getInjectWaitInPut()
      • getMetadataRequestUseSessionDatabase

        public boolean getMetadataRequestUseSessionDatabase()
      • setMetadataRequestUseSessionDatabase

        public void setMetadataRequestUseSessionDatabase​(boolean enabled)
      • getMetadataRequestUseConnectionCtx

        public boolean getMetadataRequestUseConnectionCtx()
      • setMetadataRequestUseConnectionCtx

        public void setMetadataRequestUseConnectionCtx​(boolean enabled)
      • setInjectedDelay

        public void setInjectedDelay​(int injectedDelay)
      • getTreatNTZAsUTC

        public boolean getTreatNTZAsUTC()
      • setTreatNTZAsUTC

        public void setTreatNTZAsUTC​(boolean treatNTZAsUTC)
      • getEnableHeartbeat

        public boolean getEnableHeartbeat()
      • setEnableHeartbeat

        public void setEnableHeartbeat​(boolean enableHeartbeat)
      • setHeartbeatFrequency

        public void setHeartbeatFrequency​(int frequency)
        Set the heartbeat frequency in seconds. This is the frequency with which the session token is refreshed.
        Parameters:
        frequency - heartbeat frequency in seconds
      • getHeartbeatFrequency

        public int getHeartbeatFrequency()
        Retrieve session heartbeat frequency in seconds
      • getAutoCommit

        public boolean getAutoCommit()
      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
      • getFormatDateWithTimezone

        public boolean getFormatDateWithTimezone()
      • setFormatDateWithTimezone

        public void setFormatDateWithTimezone​(boolean formatDateWithTimezone)
      • getUseSessionTimezone

        public boolean getUseSessionTimezone()
      • setUseSessionTimezone

        public void setUseSessionTimezone​(boolean useSessionTimezone)
      • getEnableCombineDescribe

        public boolean getEnableCombineDescribe()
      • setEnableCombineDescribe

        public void setEnableCombineDescribe​(boolean enableCombineDescribe)
      • isClientTelemetryEnabled

        public boolean isClientTelemetryEnabled()
      • setClientTelemetryEnabled

        public void setClientTelemetryEnabled​(boolean clientTelemetryEnabled)
      • getArrayBindStageThreshold

        public int getArrayBindStageThreshold()
      • setArrayBindStageThreshold

        public void setArrayBindStageThreshold​(int arrayBindStageThreshold)
      • getStoreTemporaryCredential

        public boolean getStoreTemporaryCredential()
      • setStoreTemporaryCredential

        public void setStoreTemporaryCredential​(boolean storeTemporaryCredential)
      • getServiceName

        public String getServiceName()
      • setServiceName

        public void setServiceName​(String serviceName)
      • setEnableConservativeMemoryUsage

        public void setEnableConservativeMemoryUsage​(boolean enableConservativeMemoryUsage)
      • isConservativeMemoryUsageEnabled

        public boolean isConservativeMemoryUsageEnabled()
      • getConservativeMemoryAdjustStep

        public int getConservativeMemoryAdjustStep()
      • setConservativeMemoryAdjustStep

        public void setConservativeMemoryAdjustStep​(int conservativeMemoryAdjustStep)
      • getClientMemoryLimit

        public int getClientMemoryLimit()
      • setClientMemoryLimit

        public void setClientMemoryLimit​(int clientMemoryLimit)
      • getQueryContextCacheSize

        public int getQueryContextCacheSize()
      • setQueryContextCacheSize

        public void setQueryContextCacheSize​(int queryContextCacheSize)
      • getClientResultChunkSize

        public int getClientResultChunkSize()
      • setClientResultChunkSize

        public void setClientResultChunkSize​(int clientResultChunkSize)
      • getOtherParameter

        public Object getOtherParameter​(String key)
      • setOtherParameter

        public void setOtherParameter​(String key,
                                      Object value)
      • getClientPrefetchThreads

        public int getClientPrefetchThreads()
      • setClientPrefetchThreads

        public void setClientPrefetchThreads​(int clientPrefetchThreads)
      • getValidateDefaultParameters

        public boolean getValidateDefaultParameters()
      • setValidateDefaultParameters

        public void setValidateDefaultParameters​(boolean validateDefaultParameters)
      • 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)
      • setUseRegionalS3EndpointsForPresignedURL

        public void setUseRegionalS3EndpointsForPresignedURL​(boolean regionalS3Endpoint)
      • getUseRegionalS3EndpointsForPresignedURL

        public boolean getUseRegionalS3EndpointsForPresignedURL()
      • getArrayBindStage

        public String getArrayBindStage()
      • setArrayBindStage

        public void setArrayBindStage​(String arrayBindStage)
      • setSessionPropertyByKey

        public void setSessionPropertyByKey​(String propertyName,
                                            Object propertyValue)
        Enables setting a value in the custom-properties map. This is used for properties that are implementation specific to the session, and not shared by the different implementations.
        Parameters:
        propertyName - A string key for the property to set.
        propertyValue - The property value.
      • getSessionPropertyByKey

        public Object getSessionPropertyByKey​(String propertyName)
        Fetch the value for a custom session property.
        Parameters:
        propertyName - The key of the session property to fetch.
      • isSafeToClose

        public abstract boolean isSafeToClose()
        Function that checks if the active session can be closed when the connection is closed. Called by SnowflakeConnectionV1.
      • getQueryStatus

        public abstract 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
      • checkProperties

        public abstract List<DriverPropertyInfo> checkProperties()
        Validates the connection properties used by this session, and returns a list of missing properties.
      • getTelemetryClient

        public abstract Telemetry getTelemetryClient()
        Returns the telemetry client, if supported, by this session. If not, should return a NoOpTelemetryClient.
      • getSqlWarnings

        public List<SFException> getSqlWarnings()
        JDBC API. Returns a list of warnings generated since starting this session, or the last time it was cleared.
      • clearSqlWarnings

        public void clearSqlWarnings()
        JDBC API. Clears the list of warnings generated since the start of the session, or the last time it was cleared.
      • getNetworkTimeoutInMilli

        public abstract int getNetworkTimeoutInMilli()
      • getAuthTimeout

        public abstract int getAuthTimeout()
      • getMaxHttpRetries

        public abstract int getMaxHttpRetries()
      • isAsyncSession

        public abstract boolean isAsyncSession()
      • getQueryContextDTO

        public abstract QueryContextDTO getQueryContextDTO()
      • setQueryContext

        public abstract void setQueryContext​(String queryContext)
      • getEnableReturnTimestampWithTimeZone

        public boolean getEnableReturnTimestampWithTimeZone()
        If true, JDBC will enable returning TIMESTAMP_WITH_TIMEZONE as column type, otherwise it will not. This function will always return true for JDBC client, so that the client JDBC will not have any behavior change. Stored proc JDBC will override this function to return the value of SP_JDBC_ENABLE_TIMESTAMP_WITH_TIMEZONE from server for backward compatibility.