Class CTBase
- Direct Known Subclasses:
CTDatabase
,CTField
,CTFullTextIndex
,CTFullTextIndexDictionary
,CTIndex
,CTRecord
,CTResultSet
,CTResultSetCriteria
,CTSegment
,CTSession
,CTTable
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Abort()
Aborts a transaction started with a call to Begin().void
Begin()
Begins a transaction using the currentBEGIN_MODE
value.void
Clears the last transaction save point.void
Commit()
Commits a transaction started with a call to Begin().boolean
Retrieves the auto commit flag.CTHANDLE
Retrieves the internal JTDB handle.int
Retrieves the currentKEEPLOCK_MODE
.int
Retrieves the currentLOCK_MODE
.int
Retrieves theOPS_MODE
for special performance-related functionality and tests operational states for critical events.int
Gets the currentBEGIN_MODE
.boolean
Checks if the locks are active.boolean
Indicates if a transaction has been started with a call to Begin(), but not terminated with a call to Commit() or Abort().boolean
Retrieves c-treeDB UNICODE mode.void
Lock
(int mode) Enables or disables record locks.void
Prepares a two-phase commit transaction to be committed.void
RestoreSavePoint
(int SavePoint) Restores a previously set save point.void
SetAutoCommit
(boolean flag) Sets the auto commit mode.void
SetHandle
(CTHANDLE Handle) Sets the internal JTDB handle.void
SetKeepLock
(int mode) Sets theKEEPLOCK_MODE
applied when an active transaction is commited or aborted by calling Abort() or Commit().void
SetOperation
(int mode, int state) Sets theOPS_MODE
for special performance-related functionality and tests operational states for critical events.int
Sets a new transaction save point.void
SetTransactionMode
(int mode) Sets theBEGIN_MODE
.void
Unlock()
Disables record locks.
-
Field Details
-
m_handle
protected CTHANDLE m_handleInternal JTDB handle
-
-
Constructor Details
-
CTBase
public CTBase()Default Constructor.
-
-
Method Details
-
IsTransActive
public boolean IsTransActive()Indicates if a transaction has been started with a call to Begin(), but not terminated with a call to Commit() or Abort().- Returns:
- true if there is a pending transaction, otherwise returns false.
- See Also:
-
Begin
Begins a transaction using the currentBEGIN_MODE
value.- Throws:
CTException
- in case of error- See Also:
-
Commit
Commits a transaction started with a call to Begin().- Throws:
CTException
- in case of error- See Also:
-
Abort
Aborts a transaction started with a call to Begin().- Throws:
CTException
- in case of error- See Also:
-
PrepareCommit
Prepares a two-phase commit transaction to be committed.- Throws:
CTException
- in case of error- See Also:
-
SetSavePoint
Sets a new transaction save point.- Returns:
- Integer with the save point number.
- Throws:
CTException
- in case of error- See Also:
-
RestoreSavePoint
Restores a previously set save point.- Parameters:
SavePoint
- Previously saved save point number.- Throws:
CTException
- in case of error- See Also:
-
ClearSavePoint
Clears the last transaction save point.- Throws:
CTException
- in case of error- See Also:
-
GetHandle
public CTHANDLE GetHandle()Retrieves the internal JTDB handle.- Returns:
- Internal JTDB handle.
- See Also:
-
SetHandle
public void SetHandle(CTHANDLE Handle) Sets the internal JTDB handle.- Parameters:
Handle
- internal JTDB handle.- See Also:
-
GetAutoCommit
public boolean GetAutoCommit()Retrieves the auto commit flag. The auto commit of transactions are invoked automatically when records are added or updated byCTRecord.Write()
method.- Returns:
- true if auto commit is enabled, otherwise returns false.
- See Also:
-
IsLockActive
public boolean IsLockActive()Checks if the locks are active. Locks are active if the current lock mode is not CTLOCK_FREE or CTLOCK_SUSPEND. Please checkLOCK_MODE
for the other modes.- Returns:
- true if locks are active, otherwise returns false.
- See Also:
-
GetLockMode
public int GetLockMode()Retrieves the currentLOCK_MODE
.- Returns:
- Current lock mode. If LOCK_MODE_FREE is returned, it indicates that no locks are currently active.
- See Also:
-
Lock
Enables or disables record locks.- Parameters:
mode
- One of the c-tree plus lock modesLOCK_MODE
.- Throws:
CTException
- in case of error- See Also:
-
Unlock
Disables record locks.- Throws:
CTException
- in case of error- See Also:
-
GetKeepLock
public int GetKeepLock()Retrieves the currentKEEPLOCK_MODE
.- Returns:
- Current keep lock mode.
- See Also:
-
SetKeepLock
Sets theKEEPLOCK_MODE
applied when an active transaction is commited or aborted by calling Abort() or Commit().- Parameters:
mode
- NewKEEPLOCK_MODE
value.- Throws:
CTException
- in case of error- See Also:
-
SetTransactionMode
Sets theBEGIN_MODE
. If the transaction mode is CTBEGIN_NONE, the ctTRNLOG mode is used to start a new transaction.- Parameters:
mode
- NewBEGIN_MODE
value.- Throws:
CTException
- in case of error- See Also:
-
GetTransactionMode
public int GetTransactionMode()Gets the currentBEGIN_MODE
.- Returns:
- Current
BEGIN_MODE
value. - See Also:
-
SetAutoCommit
Sets the auto commit mode. The auto commit of a transaction is invoked automatically when records are added or updated byCTRecord.Write()
. Automatic transactions may increase performance by reducing network traffic for single record updates since this is equivalent of performing the following class:hRecord.Begin() try { hRecord.Write(); hRecord.Commit(); } catch (CTException) { hRecord.Abort(); }
The following applies when an automatic transaction is performed:
1. An automatic transaction will only free locks acquired by the
CTRecord.Write()
method.2. If an automatic transaction is aborted because of errors detected by ctdbWriteRecord, all locks acquired by
CTRecord.Write()
are released.3. If locks are active, by calling Lock() method, an automatic transaction will not release any locks when it commits or aborts the write operation.
4. If OPS_UNLOCK_UPD is on, both commits and aborts on automatic transactions release only locks obtained within the transaction and/or locks on records updated within the transaction, regardless of whether the c-treeDB session lock state is active or not.
- Parameters:
flag
- New auto commit mode: true for enabled and false for disabled.- Throws:
CTException
- in case of error- See Also:
-
GetOperation
public int GetOperation()Retrieves theOPS_MODE
for special performance-related functionality and tests operational states for critical events.- Returns:
- Current
OPS_MODE
value. - See Also:
-
SetOperation
Sets theOPS_MODE
for special performance-related functionality and tests operational states for critical events.- Parameters:
mode
- newOPS_MODE
valuestate
- newOPS_STATE
value- Throws:
CTException
- in case of error- See Also:
-
IsUnicodeLib
public boolean IsUnicodeLib()Retrieves c-treeDB UNICODE mode.- Returns:
- true if UNICODE mode is enabled, otherwise return false.
-