org.hsqldb
Class Session
- java.lang.Object
-
- org.hsqldb.Session
-
- All Implemented Interfaces:
- SessionInterface
public class Session extends java.lang.Object implements SessionInterface
Implementation of SQL sessions.- Since:
- 1.7.0
-
-
Field Summary
Fields Modifier and Type Field and Description HsqlNameManager.HsqlNamecurrentSchemaDatabasedatabasebooleanisReadOnlyDefaultCountUpDownLatchlatchHsqlNameManager.HsqlNameloggedSchemaSessionContextsessionContextSessionDatasessionDataStatementManagerstatementManagerOrderedHashSetwaitedSessionsOrderedHashSetwaitingSessions-
Fields inherited from interface org.hsqldb.SessionInterface
INFO_AUTOCOMMIT, INFO_BOOLEAN, INFO_CATALOG, INFO_CONNECTION_READONLY, INFO_ID, INFO_INTEGER, INFO_ISOLATION, INFO_LIMIT, INFO_VARCHAR, lobStreamBlockSize, TX_READ_COMMITTED, TX_READ_UNCOMMITTED, TX_REPEATABLE_READ, TX_SERIALIZABLE
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddDeleteAction(Table table, PersistentStore store, Row row, int[] colMap)Adds a delete action to the row and the transaction manager.voidaddWarning(HsqlException warning)voidallocateResultLob(ResultLob result, java.io.InputStream inputStream)voidbeginAction(Statement cs)voidclearWarnings()voidclose()Closes this Session.voidcloseNavigator(long id)voidcommit(boolean chain)Commits any uncommited transaction this Session may have openStatementcompileStatement(java.lang.String sql)StatementcompileStatement(java.lang.String sql, int props)BlobDataIDcreateBlob(long length)ClobDataIDcreateClob(long length)voidendAction(Result result)Resultexecute(Result cmd)Executes the command encapsulated by the cmd argument.ResultexecuteCompiledStatement(Statement cs, java.lang.Object[] pvals, int timeout)ResultexecuteDirectStatement(Result cmd)ResultexecuteDirectStatement(java.lang.String sql)longgetActionTimestamp()HsqlException[]getAndClearWarnings()java.lang.ObjectgetAttribute(int id)java.util.CalendargetCalendar()java.util.CalendargetCalendarGMT()HsqlPropertiesgetClientProperties()Type.TypedComparatorgetComparator()longgetConnectTime()Getter for connectTime attribute.TimestampDatagetCurrentDate()Returns the current date, unchanged for the duration of the current execution unit (statement).HsqlNameManager.HsqlNamegetCurrentSchemaHsqlName()DatabasegetDatabase()Retrieves the Database instance to which this Session represents a connection.java.lang.StringgetDatabaseUniqueName()GranteegetGrantee()longgetId()Retrieves the session identifier for this Session.java.lang.StringgetInternalConnectionURL()intgetIsolation()JDBCConnectiongetJDBCConnection()Retreives the external JDBC connectionjava.lang.NumbergetLastIdentity()Getter for iLastIdentity attribute.HsqlExceptiongetLastWarning()intgetResultMemoryRowCount()GranteegetRole()RowSetNavigatorClientgetRows(long navigatorId, int offset, int blockSize)ScannergetScanner()java.lang.StringgetSchemaName(java.lang.String name)Same as above, but return stringjava.text.SimpleDateFormatgetSimpleDateFormatGMT()intgetStreamBlockSize()intgetTransactionSize()Count of acctions in current transaction.longgetTransactionTimestamp()UsergetUser()Retrieves the User object representing the user currently controlling this Session.java.lang.StringgetUsername()Retrieves the name, as known to the database, of the user currently controlling this Session.intgetZoneSeconds()booleanhasLocks(Statement statement)booleanisAdmin()Getter for admin attribute.booleanisAutoCommit()Getter for autoCommit attribute.booleanisClosed()Retrieves whether this Session is closed.booleanisIgnorecase()booleanisInMidTransaction()booleanisReadOnly()Getter for readonly attribute.booleanisReadOnlyDefault()voidprepareCommit()doublerandom()doublerandom(long seed)voidregisterResultLobs(Result result)voidreleaseSavepoint(java.lang.String name)Releases a savepointvoidresetSession()Clear structures and reset variables to original.voidrollback(boolean chain)Rolls back any uncommited transaction this Session may have open.voidrollbackAction(int start, long timestamp)voidrollbackToSavepoint()Performs a partial transaction ROLLBACK of current savepoint level.voidrollbackToSavepoint(java.lang.String name)Performs a partial transaction ROLLBACK to savepoint.voidsavepoint(java.lang.String name)Registers a transaction SAVEPOINT.voidsetAttribute(int id, java.lang.Object object)voidsetAutoCommit(boolean autocommit)Setter for the autocommit attribute.voidsetCatalog(java.lang.String catalog)voidsetCurrentSchemaHsqlName(HsqlNameManager.HsqlName name)voidsetIgnoreCase(boolean mode)voidsetIsolation(int level)sets ISOLATION for the next transaction onlyvoidsetIsolationDefault(int level)voidsetJDBCConnection(JDBCConnection connection)voidsetNoSQL()voidsetReadOnly(boolean readonly)sets READ ONLY for next transaction / subtransaction onlyvoidsetReadOnlyDefault(boolean readonly)voidsetResultMemoryRowCount(int count)voidsetRole(Grantee role)voidsetSchema(java.lang.String schema)voidsetUser(User user)Sets this Session's User object to the one specified by the user argument.voidsetZoneSeconds(int seconds)voidstartPhasedTransaction()voidstartTransaction()
-
-
-
Field Detail
-
database
public Database database
-
isReadOnlyDefault
public boolean isReadOnlyDefault
-
waitedSessions
public OrderedHashSet waitedSessions
-
waitingSessions
public OrderedHashSet waitingSessions
-
latch
public CountUpDownLatch latch
-
currentSchema
public HsqlNameManager.HsqlName currentSchema
-
loggedSchema
public HsqlNameManager.HsqlName loggedSchema
-
sessionContext
public SessionContext sessionContext
-
sessionData
public SessionData sessionData
-
statementManager
public StatementManager statementManager
-
-
Method Detail
-
getId
public long getId()
Retrieves the session identifier for this Session.- Specified by:
getIdin interfaceSessionInterface- Returns:
- the session identifier for this Session
-
close
public void close()
Closes this Session.- Specified by:
closein interfaceSessionInterface
-
isClosed
public boolean isClosed()
Retrieves whether this Session is closed.- Specified by:
isClosedin interfaceSessionInterface- Returns:
- true if this Session is closed
-
setIsolationDefault
public void setIsolationDefault(int level)
- Specified by:
setIsolationDefaultin interfaceSessionInterface
-
setIsolation
public void setIsolation(int level)
sets ISOLATION for the next transaction only
-
getIsolation
public int getIsolation()
- Specified by:
getIsolationin interfaceSessionInterface
-
getLastIdentity
public java.lang.Number getLastIdentity()
Getter for iLastIdentity attribute.- Returns:
- the current value
-
getDatabase
public Database getDatabase()
Retrieves the Database instance to which this Session represents a connection.- Returns:
- the Database object to which this Session is connected
-
getUsername
public java.lang.String getUsername()
Retrieves the name, as known to the database, of the user currently controlling this Session.- Returns:
- the name of the user currently connected within this Session
-
getUser
public User getUser()
Retrieves the User object representing the user currently controlling this Session.- Returns:
- this Session's User object
-
getGrantee
public Grantee getGrantee()
-
getRole
public Grantee getRole()
-
setUser
public void setUser(User user)
Sets this Session's User object to the one specified by the user argument.- Parameters:
user- the new User object for this session
-
setRole
public void setRole(Grantee role)
-
getActionTimestamp
public long getActionTimestamp()
-
addDeleteAction
public void addDeleteAction(Table table, PersistentStore store, Row row, int[] colMap)
Adds a delete action to the row and the transaction manager.- Parameters:
table- the table of the rowrow- the deleted row- Throws:
HsqlException
-
setAutoCommit
public void setAutoCommit(boolean autocommit)
Setter for the autocommit attribute.- Specified by:
setAutoCommitin interfaceSessionInterface- Parameters:
autocommit- the new value- Throws:
HsqlException
-
beginAction
public void beginAction(Statement cs)
-
endAction
public void endAction(Result result)
-
hasLocks
public boolean hasLocks(Statement statement)
-
startTransaction
public void startTransaction()
-
startPhasedTransaction
public void startPhasedTransaction()
- Specified by:
startPhasedTransactionin interfaceSessionInterface
-
prepareCommit
public void prepareCommit()
- Specified by:
prepareCommitin interfaceSessionInterface
-
commit
public void commit(boolean chain)
Commits any uncommited transaction this Session may have open- Specified by:
commitin interfaceSessionInterface- Throws:
HsqlException
-
rollback
public void rollback(boolean chain)
Rolls back any uncommited transaction this Session may have open.- Specified by:
rollbackin interfaceSessionInterface- Throws:
HsqlException
-
resetSession
public void resetSession()
Clear structures and reset variables to original. For JDBC use only.- Specified by:
resetSessionin interfaceSessionInterface
-
savepoint
public void savepoint(java.lang.String name)
Registers a transaction SAVEPOINT. A new SAVEPOINT with the name of an existing one replaces the old SAVEPOINT.- Specified by:
savepointin interfaceSessionInterface- Parameters:
name- name of the savepoint- Throws:
HsqlException- if there is no current transaction
-
rollbackToSavepoint
public void rollbackToSavepoint(java.lang.String name)
Performs a partial transaction ROLLBACK to savepoint.- Specified by:
rollbackToSavepointin interfaceSessionInterface- Parameters:
name- name of savepoint- Throws:
HsqlException
-
rollbackToSavepoint
public void rollbackToSavepoint()
Performs a partial transaction ROLLBACK of current savepoint level.- Throws:
HsqlException
-
rollbackAction
public void rollbackAction(int start, long timestamp)
-
releaseSavepoint
public void releaseSavepoint(java.lang.String name)
Releases a savepoint- Specified by:
releaseSavepointin interfaceSessionInterface- Parameters:
name- name of savepoint- Throws:
HsqlException- if name does not correspond to a savepoint
-
isInMidTransaction
public boolean isInMidTransaction()
-
setNoSQL
public void setNoSQL()
-
setIgnoreCase
public void setIgnoreCase(boolean mode)
-
isIgnorecase
public boolean isIgnorecase()
-
setReadOnly
public void setReadOnly(boolean readonly)
sets READ ONLY for next transaction / subtransaction only- Parameters:
readonly- the new value
-
setReadOnlyDefault
public void setReadOnlyDefault(boolean readonly)
- Specified by:
setReadOnlyDefaultin interfaceSessionInterface
-
isReadOnly
public boolean isReadOnly()
Getter for readonly attribute.- Returns:
- the current value
-
isReadOnlyDefault
public boolean isReadOnlyDefault()
- Specified by:
isReadOnlyDefaultin interfaceSessionInterface
-
isAutoCommit
public boolean isAutoCommit()
Getter for autoCommit attribute.- Specified by:
isAutoCommitin interfaceSessionInterface- Returns:
- the current value
-
getStreamBlockSize
public int getStreamBlockSize()
- Specified by:
getStreamBlockSizein interfaceSessionInterface
-
getJDBCConnection
public JDBCConnection getJDBCConnection()
Retreives the external JDBC connection- Specified by:
getJDBCConnectionin interfaceSessionInterface
-
setJDBCConnection
public void setJDBCConnection(JDBCConnection connection)
- Specified by:
setJDBCConnectionin interfaceSessionInterface
-
getDatabaseUniqueName
public java.lang.String getDatabaseUniqueName()
- Specified by:
getDatabaseUniqueNamein interfaceSessionInterface
-
isAdmin
public boolean isAdmin()
Getter for admin attribute.- Returns:
- the current value
-
getConnectTime
public long getConnectTime()
Getter for connectTime attribute.- Returns:
- the value
-
getTransactionSize
public int getTransactionSize()
Count of acctions in current transaction.- Returns:
- the current value
-
getTransactionTimestamp
public long getTransactionTimestamp()
-
compileStatement
public Statement compileStatement(java.lang.String sql, int props)
-
compileStatement
public Statement compileStatement(java.lang.String sql)
-
execute
public Result execute(Result cmd)
Executes the command encapsulated by the cmd argument.- Specified by:
executein interfaceSessionInterface- Parameters:
cmd- the command to execute- Returns:
- the result of executing the command
-
getRows
public RowSetNavigatorClient getRows(long navigatorId, int offset, int blockSize)
- Specified by:
getRowsin interfaceSessionInterface
-
closeNavigator
public void closeNavigator(long id)
- Specified by:
closeNavigatorin interfaceSessionInterface
-
executeDirectStatement
public Result executeDirectStatement(java.lang.String sql)
-
executeCompiledStatement
public Result executeCompiledStatement(Statement cs, java.lang.Object[] pvals, int timeout)
-
getCurrentDate
public TimestampData getCurrentDate()
Returns the current date, unchanged for the duration of the current execution unit (statement).SQL standards require that CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP are all evaluated at the same point of time in the duration of each SQL statement, no matter how long the SQL statement takes to complete.
When this method or a corresponding method for CURRENT_TIME or CURRENT_TIMESTAMP is first called in the scope of a system change number, currentMillis is set to the current system time. All further CURRENT_XXXX calls in this scope will use this millisecond value. (fredt@users)
- Specified by:
getCurrentDatein interfaceSessionInterface
-
getAttribute
public java.lang.Object getAttribute(int id)
- Specified by:
getAttributein interfaceSessionInterface
-
setAttribute
public void setAttribute(int id, java.lang.Object object)- Specified by:
setAttributein interfaceSessionInterface
-
createBlob
public BlobDataID createBlob(long length)
- Specified by:
createBlobin interfaceSessionInterface
-
createClob
public ClobDataID createClob(long length)
- Specified by:
createClobin interfaceSessionInterface
-
registerResultLobs
public void registerResultLobs(Result result)
-
allocateResultLob
public void allocateResultLob(ResultLob result, java.io.InputStream inputStream)
- Specified by:
allocateResultLobin interfaceSessionInterface
-
getInternalConnectionURL
public java.lang.String getInternalConnectionURL()
- Specified by:
getInternalConnectionURLin interfaceSessionInterface
-
setSchema
public void setSchema(java.lang.String schema)
-
setCatalog
public void setCatalog(java.lang.String catalog)
-
getSchemaName
public java.lang.String getSchemaName(java.lang.String name)
Same as above, but return string
-
setCurrentSchemaHsqlName
public void setCurrentSchemaHsqlName(HsqlNameManager.HsqlName name)
-
getCurrentSchemaHsqlName
public HsqlNameManager.HsqlName getCurrentSchemaHsqlName()
-
getResultMemoryRowCount
public int getResultMemoryRowCount()
-
setResultMemoryRowCount
public void setResultMemoryRowCount(int count)
-
addWarning
public void addWarning(HsqlException warning)
- Specified by:
addWarningin interfaceSessionInterface
-
getAndClearWarnings
public HsqlException[] getAndClearWarnings()
-
getLastWarning
public HsqlException getLastWarning()
-
clearWarnings
public void clearWarnings()
-
getZoneSeconds
public int getZoneSeconds()
- Specified by:
getZoneSecondsin interfaceSessionInterface
-
setZoneSeconds
public void setZoneSeconds(int seconds)
-
getCalendar
public java.util.Calendar getCalendar()
- Specified by:
getCalendarin interfaceSessionInterface
-
getCalendarGMT
public java.util.Calendar getCalendarGMT()
- Specified by:
getCalendarGMTin interfaceSessionInterface
-
getSimpleDateFormatGMT
public java.text.SimpleDateFormat getSimpleDateFormatGMT()
- Specified by:
getSimpleDateFormatGMTin interfaceSessionInterface
-
getComparator
public Type.TypedComparator getComparator()
-
random
public double random(long seed)
-
random
public double random()
-
getScanner
public Scanner getScanner()
- Specified by:
getScannerin interfaceSessionInterface
-
getClientProperties
public HsqlProperties getClientProperties()
- Specified by:
getClientPropertiesin interfaceSessionInterface
-
-
DataMelt 3.0 © DataMelt by jWork.ORG