Package org.h2.engine
Class Session
- java.lang.Object
-
- org.h2.engine.Session
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,CastDataProvider
- Direct Known Subclasses:
SessionLocal
,SessionRemote
public abstract class Session extends java.lang.Object implements CastDataProvider, java.lang.AutoCloseable
A local or remote session. A session represents a database connection.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Session.DynamicSettings
Dynamic settings.static class
Session.StaticSettings
Static settings.
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<java.lang.String>
sessionState
(package private) boolean
sessionStateChanged
private boolean
sessionStateUpdating
(package private) Session.StaticSettings
staticSettings
-
Constructor Summary
Constructors Constructor Description Session()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract ValueLob
addTemporaryLob(ValueLob v)
Add a temporary LOB, which is closed when the session commits.abstract void
cancel()
Cancel the current or next command (called when closing a connection).abstract void
close()
Roll back pending transactions and close the session.abstract boolean
getAutoCommit()
Check if this session is in auto-commit mode.abstract java.util.ArrayList<java.lang.String>
getClusterServers()
Get the list of the cluster servers for this session.abstract java.lang.String
getCurrentSchemaName()
Get current schema.abstract DatabaseMeta
getDatabaseMeta()
Returns database meta information.abstract DataHandler
getDataHandler()
Get the data handler object.abstract Session.DynamicSettings
getDynamicSettings()
Returns dynamic settings.abstract IsolationLevel
getIsolationLevel()
Returns the isolation level.abstract Session.StaticSettings
getStaticSettings()
Returns static settings.abstract Trace
getTrace()
Get the trace objectabstract boolean
hasPendingTransaction()
Check whether this session has a pending transaction.abstract boolean
isClosed()
Check if close was called.abstract boolean
isOldInformationSchema()
Returns whether INFORMATION_SCHEMA contains old-style tables.abstract boolean
isRemote()
Check if this session is remote or embedded.abstract CommandInterface
prepareCommand(java.lang.String sql, int fetchSize)
Parse a command and prepare it for execution.void
readSessionState()
Read the session state if necessary.(package private) void
recreateSessionState()
Re-create the session state using the stored sessionState list.void
resetThreadLocalSession(Session oldSession)
Resets old thread local session.abstract void
setAutoCommit(boolean autoCommit)
Set the auto-commit mode.abstract void
setCurrentSchemaName(java.lang.String schema)
Set current schema.abstract void
setIsolationLevel(IsolationLevel isolationLevel)
Sets the isolation level.abstract void
setNetworkConnectionInfo(NetworkConnectionInfo networkConnectionInfo)
Sets the network connection information if possible.Session
setThreadLocalSession()
Sets this session as thread local session, if this session is a local session.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.h2.engine.CastDataProvider
currentTimestamp, currentTimeZone, getJavaObjectSerializer, getMode, zeroBasedEnums
-
-
-
-
Field Detail
-
sessionState
private java.util.ArrayList<java.lang.String> sessionState
-
sessionStateChanged
boolean sessionStateChanged
-
sessionStateUpdating
private boolean sessionStateUpdating
-
staticSettings
volatile Session.StaticSettings staticSettings
-
-
Method Detail
-
getClusterServers
public abstract 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
public abstract CommandInterface prepareCommand(java.lang.String sql, int fetchSize)
Parse a command and prepare it for execution.- Parameters:
sql
- the SQL statementfetchSize
- the number of rows to fetch in one step- Returns:
- the prepared command
-
close
public abstract void close()
Roll back pending transactions and close the session.- Specified by:
close
in interfacejava.lang.AutoCloseable
-
getTrace
public abstract Trace getTrace()
Get the trace object- Returns:
- the trace object
-
isClosed
public abstract boolean isClosed()
Check if close was called.- Returns:
- if the session has been closed
-
getDataHandler
public abstract DataHandler getDataHandler()
Get the data handler object.- Returns:
- the data handler
-
hasPendingTransaction
public abstract boolean hasPendingTransaction()
Check whether this session has a pending transaction.- Returns:
- true if it has
-
cancel
public abstract void cancel()
Cancel the current or next command (called when closing a connection).
-
getAutoCommit
public abstract boolean getAutoCommit()
Check if this session is in auto-commit mode.- Returns:
- true if the session is in auto-commit mode
-
setAutoCommit
public abstract void setAutoCommit(boolean autoCommit)
Set the auto-commit mode. This call doesn't commit the current transaction.- Parameters:
autoCommit
- the new value
-
addTemporaryLob
public abstract ValueLob addTemporaryLob(ValueLob v)
Add a temporary LOB, which is closed when the session commits.- Parameters:
v
- the value- Returns:
- the specified value
-
isRemote
public abstract boolean isRemote()
Check if this session is remote or embedded.- Returns:
- true if this session is remote
-
setCurrentSchemaName
public abstract void setCurrentSchemaName(java.lang.String schema)
Set current schema.- Parameters:
schema
- the schema name
-
getCurrentSchemaName
public abstract java.lang.String getCurrentSchemaName()
Get current schema.- Returns:
- the current schema name
-
setNetworkConnectionInfo
public abstract void setNetworkConnectionInfo(NetworkConnectionInfo networkConnectionInfo)
Sets the network connection information if possible.- Parameters:
networkConnectionInfo
- the network connection information
-
getIsolationLevel
public abstract IsolationLevel getIsolationLevel()
Returns the isolation level.- Returns:
- the isolation level
-
setIsolationLevel
public abstract void setIsolationLevel(IsolationLevel isolationLevel)
Sets the isolation level.- Parameters:
isolationLevel
- the isolation level to set
-
getStaticSettings
public abstract Session.StaticSettings getStaticSettings()
Returns static settings. These settings cannot be changed during lifecycle of session.- Returns:
- static settings
-
getDynamicSettings
public abstract Session.DynamicSettings getDynamicSettings()
Returns dynamic settings. These settings can be changed during lifecycle of session.- Returns:
- dynamic settings
-
getDatabaseMeta
public abstract DatabaseMeta getDatabaseMeta()
Returns database meta information.- Returns:
- database meta information
-
isOldInformationSchema
public abstract boolean isOldInformationSchema()
Returns whether INFORMATION_SCHEMA contains old-style tables.- Returns:
- whether INFORMATION_SCHEMA contains old-style tables
-
recreateSessionState
void recreateSessionState()
Re-create the session state using the stored sessionState list.
-
readSessionState
public void readSessionState()
Read the session state if necessary.
-
setThreadLocalSession
public Session setThreadLocalSession()
Sets this session as thread local session, if this session is a local session.- Returns:
- old thread local session, or
null
-
resetThreadLocalSession
public void resetThreadLocalSession(Session oldSession)
Resets old thread local session.- Parameters:
oldSession
- the old thread local session, ornull
-
-