Package com.databricks.jdbc.api.impl

## Class DatabricksSession

- java.lang.Object
- - com.databricks.jdbc.api.impl.DatabricksSession

All Implemented Interfaces:
  `IDatabricksSession`

    public class DatabricksSession
    extends Object
    implements IDatabricksSession

Implementation of `IDatabricksSession`, which maintains an underlying session in SQL Gateway.

### Constructor Summary

Constructors
`DatabricksSession​(IDatabricksConnectionContext connectionContext)` Creates an instance of Databricks session for given connection context
`DatabricksSession​(IDatabricksConnectionContext connectionContext, IDatabricksClient testDatabricksClient)` Constructor method to be used for mocking in a test case.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `close()` Closes the session.
`void` `forceClose()`
`boolean` `getAutoCommit()` Retrieves the current auto-commit mode for this session.
`String` `getCatalog()` Returns default catalog associated with the session
`Map<String,​String>` `getClientInfoProperties()` Returns the client info properties
`CompressionCodec` `getCompressionCodec()` Returns the compression algorithm used on results data
`IDatabricksComputeResource` `getComputeResource()` Get the warehouse associated with the session.
`String` `getConfigValue​(String name)`
`IDatabricksConnectionContext` `getConnectionContext()` Returns the associated connection context for the session
`String` `getCurrentCatalog()` Gets the current catalog from the database
`IDatabricksClient` `getDatabricksClient()` Returns the client for connecting to Databricks server
`IDatabricksMetadataClient` `getDatabricksMetadataClient()` Returns the metadata client
`String` `getSchema()` Returns default schema associated with the session
`Map<String,​String>` `getSessionConfigs()` Returns the session configs
`String` `getSessionId()` Get the unique session-Id associated with the session.
`ImmutableSessionInfo` `getSessionInfo()`
`boolean` `isOpen()` Checks if session is open and valid.
`void` `open()` Opens a new session.
`void` `setAutoCommit​(boolean autoCommit)` Sets the auto-commit mode for this session.
`void` `setCatalog​(String catalog)` Sets the default catalog
`void` `setClientInfoProperty​(String name, String value)` Sets the client info property
`void` `setEmptyMetadataClient()`
`void` `setSchema​(String schema)` Sets the default schema
`void` `setSessionConfig​(String name, String value)` Sets the session config
`String` `toString()` Extracts session to a string

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

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

### Constructor Detail

#### DatabricksSession

    public DatabricksSession​(IDatabricksConnectionContext connectionContext)
                      throws DatabricksSQLException

Creates an instance of Databricks session for given connection context

Parameters:
  `connectionContext` - underlying connection context
Throws:
  `DatabricksSQLException`

#### DatabricksSession

    public DatabricksSession​(IDatabricksConnectionContext connectionContext,
                             IDatabricksClient testDatabricksClient)

Constructor method to be used for mocking in a test case.

### Method Detail

#### getSessionId

    @Nullable
    public String getSessionId()

Description copied from interface: `IDatabricksSession`
Get the unique session-Id associated with the session.

Specified by:
  `getSessionId` in interface `IDatabricksSession`
Returns:
  session-Id

#### getSessionInfo

    @Nullable
    public ImmutableSessionInfo getSessionInfo()

Specified by:
  `getSessionInfo` in interface `IDatabricksSession`

#### getComputeResource

    public IDatabricksComputeResource getComputeResource()

Description copied from interface: `IDatabricksSession`
Get the warehouse associated with the session.

Specified by:
  `getComputeResource` in interface `IDatabricksSession`
Returns:
  warehouse-Id

#### getCompressionCodec

    public CompressionCodec getCompressionCodec()

Description copied from interface: `IDatabricksSession`
Returns the compression algorithm used on results data

Specified by:
  `getCompressionCodec` in interface `IDatabricksSession`
Returns:
  the compression codec

#### isOpen

    public boolean isOpen()

Description copied from interface: `IDatabricksSession`
Checks if session is open and valid.

Specified by:
  `isOpen` in interface `IDatabricksSession`
Returns:
  true if session is open

#### open

    public void open()
              throws SQLException

Description copied from interface: `IDatabricksSession`
Opens a new session.

Specified by:
  `open` in interface `IDatabricksSession`
Throws:
  `SQLException`

#### close

    public void close()
               throws SQLException

Description copied from interface: `IDatabricksSession`
Closes the session.

Specified by:
  `close` in interface `IDatabricksSession`
Throws:
  `SQLException`

#### getDatabricksClient

    public IDatabricksClient getDatabricksClient()

Description copied from interface: `IDatabricksSession`
Returns the client for connecting to Databricks server

Specified by:
  `getDatabricksClient` in interface `IDatabricksSession`
Returns:
  the Databricks client

#### getDatabricksMetadataClient

    public IDatabricksMetadataClient getDatabricksMetadataClient()

Description copied from interface: `IDatabricksSession`
Returns the metadata client

Specified by:
  `getDatabricksMetadataClient` in interface `IDatabricksSession`
Returns:
  the Databricks metadata client

#### getCatalog

    public String getCatalog()

Description copied from interface: `IDatabricksSession`
Returns default catalog associated with the session

Specified by:
  `getCatalog` in interface `IDatabricksSession`
Returns:
  the default catalog

#### setCatalog

    public void setCatalog​(String catalog)

Description copied from interface: `IDatabricksSession`
Sets the default catalog

Specified by:
  `setCatalog` in interface `IDatabricksSession`
Parameters:
  `catalog` - the catalog to set

#### getSchema

    public String getSchema()

Description copied from interface: `IDatabricksSession`
Returns default schema associated with the session

Specified by:
  `getSchema` in interface `IDatabricksSession`
Returns:
  the default schema

#### setSchema

    public void setSchema​(String schema)

Description copied from interface: `IDatabricksSession`
Sets the default schema

Specified by:
  `setSchema` in interface `IDatabricksSession`
Parameters:
  `schema` - the schema to set

#### toString

    public String toString()

Description copied from interface: `IDatabricksSession`
Extracts session to a string

Specified by:
  `toString` in interface `IDatabricksSession`
Overrides:
  `toString` in class `Object`

#### getSessionConfigs

    public Map<String,​String> getSessionConfigs()

Description copied from interface: `IDatabricksSession`
Returns the session configs

Specified by:
  `getSessionConfigs` in interface `IDatabricksSession`
Returns:
  map of session configuration key-value pairs

#### setSessionConfig

    public void setSessionConfig​(String name,
                                 String value)

Description copied from interface: `IDatabricksSession`
Sets the session config

Specified by:
  `setSessionConfig` in interface `IDatabricksSession`
Parameters:
  `name` - the configuration name
  `value` - the configuration value

#### getClientInfoProperties

    public Map<String,​String> getClientInfoProperties()

Description copied from interface: `IDatabricksSession`
Returns the client info properties

Specified by:
  `getClientInfoProperties` in interface `IDatabricksSession`

#### getConfigValue

    public String getConfigValue​(String name)

Specified by:
  `getConfigValue` in interface `IDatabricksSession`

#### setClientInfoProperty

    public void setClientInfoProperty​(String name,
                                      String value)

Description copied from interface: `IDatabricksSession`
Sets the client info property

Specified by:
  `setClientInfoProperty` in interface `IDatabricksSession`

#### getConnectionContext

    public IDatabricksConnectionContext getConnectionContext()

Description copied from interface: `IDatabricksSession`
Returns the associated connection context for the session

Specified by:
  `getConnectionContext` in interface `IDatabricksSession`

#### getCurrentCatalog

    public String getCurrentCatalog()
                             throws DatabricksSQLException

Description copied from interface: `IDatabricksSession`
Gets the current catalog from the database

Specified by:
  `getCurrentCatalog` in interface `IDatabricksSession`
Throws:
  `DatabricksSQLException`

#### setEmptyMetadataClient

    public void setEmptyMetadataClient()

Specified by:
  `setEmptyMetadataClient` in interface `IDatabricksSession`

#### forceClose

    public void forceClose()

Specified by:
  `forceClose` in interface `IDatabricksSession`

#### setAutoCommit

    public void setAutoCommit​(boolean autoCommit)

Description copied from interface: `IDatabricksSession`
Sets the auto-commit mode for this session.

Specified by:
  `setAutoCommit` in interface `IDatabricksSession`
Parameters:
  `autoCommit` - true to enable auto-commit; false to disable

#### getAutoCommit

    public boolean getAutoCommit()

Description copied from interface: `IDatabricksSession`
Retrieves the current auto-commit mode for this session.

Specified by:
  `getAutoCommit` in interface `IDatabricksSession`
Returns:
  true if auto-commit mode is enabled; false otherwise