org.h2.engine

## Interface SessionInterface

All Superinterfaces:
  java.lang.AutoCloseable, java.io.Closeable

All Known Implementing Classes:
  Session, SessionRemote

    public interface SessionInterface
    extends java.io.Closeable

A local or remote session. A session represents a database connection.

### Method Summary

Methods
`void` `addTemporaryLob(Value v)` Add a temporary LOB, which is closed when the session commits.
`void` `afterWriting()` Called after writing has ended.
`void` `cancel()` Cancel the current or next command (called when closing a connection).
`void` `close()` Roll back pending transactions and close the session.
`boolean` `getAutoCommit()` Check if this session is in auto-commit mode.
`java.util.ArrayList<java.lang.String>` `getClusterServers()` Get the list of the cluster servers for this session.
`java.lang.String` `getCurrentSchemaName()` Get current schema.
`DataHandler` `getDataHandler()` Get the data handler object.
`int` `getPowerOffCount()` Get the number of disk operations before power failure is simulated.
`Trace` `getTrace()` Get the trace object
`boolean` `hasPendingTransaction()` Check whether this session has a pending transaction.
`boolean` `isClosed()` Check if close was called.
`boolean` `isReconnectNeeded(boolean write)` Check if the database changed and therefore reconnecting is required.
`boolean` `isRemote()` Check if this session is remote or embedded.
`CommandInterface` `prepareCommand(java.lang.String sql, int fetchSize)` Parse a command and prepare it for execution.
`SessionInterface` `reconnect(boolean write)` Close the connection and open a new connection.
`void` `setAutoCommit(boolean autoCommit)` Set the auto-commit mode.
`void` `setCurrentSchemaName(java.lang.String schema)` Set current schema.
`void` `setPowerOffCount(int i)` Set the number of disk operations before power failure is simulated.

### Method Detail

#### getClusterServers

    java.util.ArrayList<java.lang.String> getClusterServers()

Get the list of the cluster servers for this session.

Returns:
  A list of "ip:port" strings for the cluster servers in this session.

#### prepareCommand

    CommandInterface prepareCommand(java.lang.String sql,
                                  int fetchSize)

Parse a command and prepare it for execution.

Parameters:
  `sql` - the SQL statement
  `fetchSize` - the number of rows to fetch in one step
Returns:
  the prepared command

#### close

    void close()

Roll back pending transactions and close the session.

Specified by:
  `close` in interface `java.lang.AutoCloseable`
Specified by:
  `close` in interface `java.io.Closeable`

#### getTrace

    Trace getTrace()

Get the trace object

Returns:
  the trace object

#### isClosed

    boolean isClosed()

Check if close was called.

Returns:
  if the session has been closed

#### getPowerOffCount

    int getPowerOffCount()

Get the number of disk operations before power failure is simulated. This is used for testing. If not set, 0 is returned

Returns:
  the number of operations, or 0

#### setPowerOffCount

    void setPowerOffCount(int i)

Set the number of disk operations before power failure is simulated. To disable the countdown, use 0.

Parameters:
  `i` - the number of operations

#### getDataHandler

    DataHandler getDataHandler()

Get the data handler object.

Returns:
  the data handler

#### hasPendingTransaction

    boolean hasPendingTransaction()

Check whether this session has a pending transaction.

Returns:
  true if it has

#### cancel

    void cancel()

Cancel the current or next command (called when closing a connection).

#### isReconnectNeeded

    boolean isReconnectNeeded(boolean write)

Check if the database changed and therefore reconnecting is required.

Parameters:
  `write` - if the next operation may be writing
Returns:
  true if reconnecting is required

#### reconnect

    SessionInterface reconnect(boolean write)

Close the connection and open a new connection.

Parameters:
  `write` - if the next operation may be writing
Returns:
  the new connection

#### afterWriting

    void afterWriting()

Called after writing has ended. It needs to be called after isReconnectNeeded(true) returned false.

#### getAutoCommit

    boolean getAutoCommit()

Check if this session is in auto-commit mode.

Returns:
  true if the session is in auto-commit mode

#### setAutoCommit

    void setAutoCommit(boolean autoCommit)

Set the auto-commit mode. This call doesn't commit the current transaction.

Parameters:
  `autoCommit` - the new value

#### addTemporaryLob

    void addTemporaryLob(Value v)

Add a temporary LOB, which is closed when the session commits.

Parameters:
  `v` - the value

#### isRemote

    boolean isRemote()

Check if this session is remote or embedded.

Returns:
  true if this session is remote

#### setCurrentSchemaName

    void setCurrentSchemaName(java.lang.String schema)

Set current schema.

Parameters:
  `schema` - the schema name

#### getCurrentSchemaName

    java.lang.String getCurrentSchemaName()

Get current schema.

Returns:
  the current schema name