# 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
Constructor
Description
`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

Modifier and Type
Method
Description
`void`
`close()`
Closes the session.
`void`
`forceClose()`
`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`
`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 Details

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

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

### 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 DatabricksSQLException
Description copied from interface: `IDatabricksSession`
Opens a new session.

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

### close

public void close() throws DatabricksSQLException
Description copied from interface: `IDatabricksSession`
Closes the session.

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

### getDatabricksClient

public IDatabricksClient getDatabricksClient()
Description copied from interface: `IDatabricksSession`
Returns the client for connecting to Databricks server

Specified by:
  `getDatabricksClient` in interface `IDatabricksSession`

### getDatabricksMetadataClient

public IDatabricksMetadataClient getDatabricksMetadataClient()
Description copied from interface: `IDatabricksSession`
Returns the metadata client

Specified by:
  `getDatabricksMetadataClient` in interface `IDatabricksSession`

### getCatalog

public String getCatalog()
Description copied from interface: `IDatabricksSession`
Returns default catalog associated with the session

Specified by:
  `getCatalog` in interface `IDatabricksSession`

### setCatalog

public void setCatalog(String catalog)
Description copied from interface: `IDatabricksSession`
Sets the default catalog

Specified by:
  `setCatalog` in interface `IDatabricksSession`

### getSchema

public String getSchema()
Description copied from interface: `IDatabricksSession`
Returns default schema associated with the session

Specified by:
  `getSchema` in interface `IDatabricksSession`

### setSchema

public void setSchema(String schema)
Description copied from interface: `IDatabricksSession`
Sets the default schema

Specified by:
  `setSchema` in interface `IDatabricksSession`

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

### setSessionConfig

public void setSessionConfig(String name, String value)
Description copied from interface: `IDatabricksSession`
Sets the session config

Specified by:
  `setSessionConfig` in interface `IDatabricksSession`

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