Top Description Inners Fields Constructors Methods
org.h2.engine

public abstract Class Session

extends Object
implements CastDataProvider, AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable, org.h2.engine.CastDataProvider
Known Direct Subclasses
org.h2.engine.SessionLocal, org.h2.engine.SessionRemote
Imports
java.util.ArrayList, java.util.concurrent.locks.ReentrantLock, org.h2.command.CommandInterface, org.h2.jdbc.meta.DatabaseMeta, org.h2.message.Trace, org.h2.result.ResultInterface, org.h2.store.DataHandler, org.h2.util.NetworkConnectionInfo, .TimeZoneProvider, .Utils, org.h2.value.ValueLob

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Session.DynamicSettings

Dynamic settings.

public static class
Session.StaticSettings

Static settings.

Field Summary

Modifier and TypeField and Description
private final ReentrantLock
private ArrayList<String>
pack-priv boolean
private boolean
pack-priv volatile Session.StaticSettings

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public abstract ValueLob

Returns:

the specified value
addTemporaryLob
(ValueLob
the value
v
)

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

public abstract void
cancel()

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

public abstract void
close()

Redeclares java.lang.AutoCloseable.close.

Roll back pending transactions and close the session.

public abstract boolean

Returns:

true if the session is in auto-commit mode
getAutoCommit
()

Check if this session is in auto-commit mode.

public abstract ArrayList<String>

Returns:

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

Get the list of the cluster servers for this session.

public abstract String

Returns:

the current schema name
getCurrentSchemaName
()

Get current schema.

public abstract DatabaseMeta

Returns:

database meta information
getDatabaseMeta
()

Returns database meta information.

public abstract DataHandler

Returns:

the data handler
getDataHandler
()

Get the data handler object.

public abstract Session.DynamicSettings

Returns:

dynamic settings
getDynamicSettings
()

Returns dynamic settings.

public abstract IsolationLevel

Returns:

the isolation level
getIsolationLevel
()

Returns the isolation level.

public abstract Session.StaticSettings

Returns:

static settings
getStaticSettings
()

Returns static settings.

public abstract Trace

Returns:

the trace object
getTrace
()

Get the trace object

public abstract boolean

Returns:

true if it has
hasPendingTransaction
()

Check whether this session has a pending transaction.

public abstract boolean

Returns:

if the session has been closed
isClosed
()

Check if close was called.

public final boolean

Returns:

true if it locked by the current thread, false if it is locked by another thread or is not locked at all
isLockedByCurrentThread
()

Returns whether this session is locked by the current thread.

public abstract boolean

Returns:

whether INFORMATION_SCHEMA contains old-style tables
isOldInformationSchema
()

Returns whether INFORMATION_SCHEMA contains old-style tables.

public abstract boolean

Returns:

true if this session is remote
isRemote
()

Check if this session is remote or embedded.

public final void
lock()

Locks this session with a reentrant lock.

public abstract CommandInterface

Returns:

the prepared command
prepareCommand
(String
the SQL statement
sql
,
int
the number of rows to fetch in one step
fetchSize
)

Parse a command and prepare it for execution.

public void
readSessionState()

Read the session state if necessary.

pack-priv void
recreateSessionState()

Re-create the session state using the stored sessionState list.

public void
resetThreadLocalSession(Session
the old thread local session, or null
oldSession
)

Resets old thread local session.

public abstract void
setAutoCommit(boolean
the new value
autoCommit
)

Set the auto-commit mode.

public abstract void
setCurrentSchemaName(String
the schema name
schema
)

Set current schema.

public abstract void
setIsolationLevel(IsolationLevel
the isolation level to set
isolationLevel
)

Sets the isolation level.

public abstract void
setNetworkConnectionInfo(NetworkConnectionInfo
the network connection information
networkConnectionInfo
)

Sets the network connection information if possible.

public Session

Returns:

old thread local session, or null
setThreadLocalSession
()

Sets this session as thread local session, if this session is a local session.

public final void
unlock()

Unlocks this session.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

lockback to summary
private final ReentrantLock lock
sessionStateback to summary
private ArrayList<String> sessionState
sessionStateChangedback to summary
pack-priv boolean sessionStateChanged
sessionStateUpdatingback to summary
private boolean sessionStateUpdating
staticSettingsback to summary
pack-priv volatile Session.StaticSettings staticSettings

Constructor Detail

Sessionback to summary
pack-priv Session()

Method Detail

addTemporaryLobback to summary
public abstract ValueLob addTemporaryLob(ValueLob v)

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

Parameters
v:ValueLob

the value

Returns:ValueLob

the specified value

cancelback to summary
public abstract void cancel()

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

closeback to summary
public abstract void close()

Redeclares java.lang.AutoCloseable.close.

Roll back pending transactions and close the session.

Annotations
@Override
getAutoCommitback to summary
public abstract boolean getAutoCommit()

Check if this session is in auto-commit mode.

Returns:boolean

true if the session is in auto-commit mode

getClusterServersback to summary
public abstract ArrayList<String> getClusterServers()

Get the list of the cluster servers for this session.

Returns:ArrayList<String>

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

getCurrentSchemaNameback to summary
public abstract String getCurrentSchemaName()

Get current schema.

Returns:String

the current schema name

getDatabaseMetaback to summary
public abstract DatabaseMeta getDatabaseMeta()

Returns database meta information.

Returns:DatabaseMeta

database meta information

getDataHandlerback to summary
public abstract DataHandler getDataHandler()

Get the data handler object.

Returns:DataHandler

the data handler

getDynamicSettingsback to summary
public abstract Session.DynamicSettings getDynamicSettings()

Returns dynamic settings. These settings can be changed during lifecycle of session.

Returns:Session.DynamicSettings

dynamic settings

getIsolationLevelback to summary
public abstract IsolationLevel getIsolationLevel()

Returns the isolation level.

Returns:IsolationLevel

the isolation level

getStaticSettingsback to summary
public abstract Session.StaticSettings getStaticSettings()

Returns static settings. These settings cannot be changed during lifecycle of session.

Returns:Session.StaticSettings

static settings

getTraceback to summary
public abstract Trace getTrace()

Get the trace object

Returns:Trace

the trace object

hasPendingTransactionback to summary
public abstract boolean hasPendingTransaction()

Check whether this session has a pending transaction.

Returns:boolean

true if it has

isClosedback to summary
public abstract boolean isClosed()

Check if close was called.

Returns:boolean

if the session has been closed

isLockedByCurrentThreadback to summary
public final boolean isLockedByCurrentThread()

Returns whether this session is locked by the current thread.

Returns:boolean

true if it locked by the current thread, false if it is locked by another thread or is not locked at all

isOldInformationSchemaback to summary
public abstract boolean isOldInformationSchema()

Returns whether INFORMATION_SCHEMA contains old-style tables.

Returns:boolean

whether INFORMATION_SCHEMA contains old-style tables

isRemoteback to summary
public abstract boolean isRemote()

Check if this session is remote or embedded.

Returns:boolean

true if this session is remote

lockback to summary
public final void lock()

Locks this session with a reentrant lock.

final Session session = ...;
session.lock();
try {
    ...
} finally {
    session.unlock();
}
prepareCommandback to summary
public abstract CommandInterface prepareCommand(String sql, int fetchSize)

Parse a command and prepare it for execution.

Parameters
sql:String

the SQL statement

fetchSize:int

the number of rows to fetch in one step

Returns:CommandInterface

the prepared command

readSessionStateback to summary
public void readSessionState()

Read the session state if necessary.

recreateSessionStateback to summary
pack-priv void recreateSessionState()

Re-create the session state using the stored sessionState list.

resetThreadLocalSessionback to summary
public void resetThreadLocalSession(Session oldSession)

Resets old thread local session.

Parameters
oldSession:Session

the old thread local session, or null

setAutoCommitback to summary
public abstract void setAutoCommit(boolean autoCommit)

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

Parameters
autoCommit:boolean

the new value

setCurrentSchemaNameback to summary
public abstract void setCurrentSchemaName(String schema)

Set current schema.

Parameters
schema:String

the schema name

setIsolationLevelback to summary
public abstract void setIsolationLevel(IsolationLevel isolationLevel)

Sets the isolation level.

Parameters
isolationLevel:IsolationLevel

the isolation level to set

setNetworkConnectionInfoback to summary
public abstract void setNetworkConnectionInfo(NetworkConnectionInfo networkConnectionInfo)

Sets the network connection information if possible.

Parameters
networkConnectionInfo:NetworkConnectionInfo

the network connection information

setThreadLocalSessionback to summary
public Session setThreadLocalSession()

Sets this session as thread local session, if this session is a local session.

Returns:Session

old thread local session, or null

unlockback to summary
public final void unlock()

Unlocks this session.

See Also
lock()
org.h2.engine back to summary

public final Class Session.DynamicSettings

extends Object
Class Inheritance

Dynamic settings.

Field Summary

Modifier and TypeField and Description
public final Mode
mode

The database mode.

public final TimeZoneProvider
timeZone

The current time zone.

Constructor Summary

AccessConstructor and Description
public
DynamicSettings(Mode
the database mode
mode
,
TimeZoneProvider
the current time zone
timeZone
)

Creates new instance of dynamic settings.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

modeback to summary
public final Mode mode

The database mode.

timeZoneback to summary
public final TimeZoneProvider timeZone

The current time zone.

Constructor Detail

DynamicSettingsback to summary
public DynamicSettings(Mode mode, TimeZoneProvider timeZone)

Creates new instance of dynamic settings.

Parameters
mode:Mode

the database mode

timeZone:TimeZoneProvider

the current time zone

org.h2.engine back to summary

public final Class Session.StaticSettings

extends Object
Class Inheritance

Static settings.

Field Summary

Modifier and TypeField and Description
public final boolean
caseInsensitiveIdentifiers

Whether all identifiers are case insensitive.

public final boolean
databaseToLower

Whether unquoted identifiers are converted to lower case.

public final boolean
databaseToUpper

Whether unquoted identifiers are converted to upper case.

Constructor Summary

AccessConstructor and Description
public
StaticSettings(boolean
whether unquoted identifiers are converted to upper case
databaseToUpper
,
boolean
whether unquoted identifiers are converted to lower case
databaseToLower
,
boolean
whether all identifiers are case insensitive
caseInsensitiveIdentifiers
)

Creates new instance of static settings.

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

caseInsensitiveIdentifiersback to summary
public final boolean caseInsensitiveIdentifiers

Whether all identifiers are case insensitive.

databaseToLowerback to summary
public final boolean databaseToLower

Whether unquoted identifiers are converted to lower case.

databaseToUpperback to summary
public final boolean databaseToUpper

Whether unquoted identifiers are converted to upper case.

Constructor Detail

StaticSettingsback to summary
public StaticSettings(boolean databaseToUpper, boolean databaseToLower, boolean caseInsensitiveIdentifiers)

Creates new instance of static settings.

Parameters
databaseToUpper:boolean

whether unquoted identifiers are converted to upper case

databaseToLower:boolean

whether unquoted identifiers are converted to lower case

caseInsensitiveIdentifiers:boolean

whether all identifiers are case insensitive