org.h2.engine
Interface SessionInterface

All Known Implementing Classes:
Session, SessionRemote, SessionWithState

public interface SessionInterface

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


Method Summary
 void cancel()
          Cancel the current or next command (called when closing a connection).
 void close()
          Roll back pending transactions and close the session.
 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 isClosed()
          Check if close was called.
 boolean isReconnectNeeded(boolean write)
          Check if the database changed and therefore reconnecting is required.
 CommandInterface prepareCommand(java.lang.String sql, int fetchSize)
          Parse a command and prepare it for execution.
 SessionInterface reconnect()
          Close the connection and open a new connection.
 void setPowerOffCount(int i)
          Set the number of disk operations before power failure is simulated.
 

Method Detail

prepareCommand

CommandInterface prepareCommand(java.lang.String sql,
                                int fetchSize)
                                throws java.sql.SQLException
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
Throws:
java.sql.SQLException

close

void close()
           throws java.sql.SQLException
Roll back pending transactions and close the session.

Throws:
java.sql.SQLException

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)
                      throws java.sql.SQLException
Set the number of disk operations before power failure is simulated. To disable the countdown, use 0.

Parameters:
i - the number of operations
Throws:
java.sql.SQLException

getDataHandler

DataHandler getDataHandler()
Get the data handler object.

Returns:
the data handler

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()
                           throws java.sql.SQLException
Close the connection and open a new connection.

Returns:
the new connection
Throws:
java.sql.SQLException