Class SqlJetEngine
java.lang.Object
org.tmatesoft.sqljet.core.table.engine.SqlJetEngine
- Direct Known Subclasses:
SqlJetDb,SqlJetMapDb
- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ISqlJetBtreeprotected ISqlJetDbHandleprotected Fileprotected static final ISqlJetFileSystemsManagerprotected ISqlJetFileSystemprotected booleanprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionSqlJetEngine(File file, boolean writable) SqlJetEngine(File file, boolean writable, String fsName) SqlJetEngine(File file, boolean writable, ISqlJetFileSystem fs) -
Method Summary
Modifier and TypeMethodDescriptionvoidBegin transaction.protected voidvoidclose()Close connection to database.protected voidvoidcommit()Commits transaction.protected voidfinalize()Get busy handler.intGet cache size (in count of pages).getFile()Get jounrnal modegetMutex()Retruns threading synchronization mutex.Returns database options.Get safety levelprotected SqlJetSchemabooleanReturns true if a transaction is active.booleanisOpen()Checks is database open.booleanCheck write access to data base.voidopen()Opens connection to database.protected voidReads database schema and options.voidRefreshes database schema.voidregisterFileSystem(ISqlJetFileSystem fs, boolean isDefault) voidrollback()Rolls back transaction.protected ObjectRuns transaction.voidsetBusyHandler(ISqlJetBusyHandler busyHandler) Set busy handler.voidsetCacheSize(int cacheSize) Set cache size (in count of pages).voidsetJournalMode(SqlJetPagerJournalMode journalMode) Set journal modevoidsetSafetyLevel(SqlJetSafetyLevel safetyLevel) Set safety levelvoid
-
Field Details
-
FILE_SYSTEM_MANAGER
-
fileSystem
-
writable
protected boolean writable -
dbHandle
-
btree
-
open
protected boolean open -
file
-
-
Constructor Details
-
SqlJetEngine
-
SqlJetEngine
- Parameters:
file-writable-fs-
-
SqlJetEngine
- Parameters:
file-writable-fsName-- Throws:
SqlJetException
-
-
Method Details
-
registerFileSystem
- Parameters:
fs-isDefault-- Throws:
SqlJetException
-
unregisterFileSystem
- Parameters:
fs-- Throws:
SqlJetException
-
getFile
- Returns:
- database file this engine is created for.
-
isWritable
Check write access to data base.- Returns:
- true if modification is allowed
- Throws:
SqlJetException
-
getFileSystem
-
isOpen
public boolean isOpen()Checks is database open.- Returns:
- true if database is open.
-
checkOpen
- Throws:
SqlJetException
-
open
Opens connection to database. It does not create any locking on database. First lock will be created when be called any method which requires real access to options or schema.
- Throws:
SqlJetException- if any trouble with access to file or database format.
-
runSynchronized
- Throws:
SqlJetException
-
close
Close connection to database. It is safe to call this method if database connections is closed already.- Throws:
SqlJetException- it is possible to get exception if there is actvie transaction and rollback did not success.
-
closeResources
- Throws:
SqlJetException
-
finalize
-
readSchema
Reads database schema and options.- Throws:
SqlJetException
-
getOptions
Returns database options.- Returns:
- options of this database.
- Throws:
SqlJetException
-
refreshSchema
Refreshes database schema.- Throws:
SqlJetException
-
getSchemaInternal
- Throws:
SqlJetException
-
getBusyHandler
Get busy handler.- Returns:
- the busy handler.
-
setBusyHandler
Set busy handler. Busy handler treats situation when database is locked by other process or thread.- Parameters:
busyHandler- the busy handler.
-
getMutex
Retruns threading synchronization mutex.- Returns:
- Semaphore instance used to synchronize database access from multiple threads within the same process.
-
setCacheSize
Set cache size (in count of pages).- Parameters:
cacheSize- the count of pages which can hold cache.- Throws:
SqlJetException
-
getCacheSize
Get cache size (in count of pages).- Returns:
- the count of pages which can hold cache.
- Throws:
SqlJetException
-
setSafetyLevel
Set safety level- Parameters:
safetyLevel-- Throws:
SqlJetException
-
setJournalMode
Set journal mode- Parameters:
journalMode-- Throws:
SqlJetException
-
getSafetyLevel
Get safety level- Returns:
- the safety level set.
- Throws:
SqlJetException
-
getJournalMode
Get jounrnal mode- Returns:
- the safety level set.
- Throws:
SqlJetException
-
isInTransaction
public boolean isInTransaction()Returns true if a transaction is active.- Returns:
- true if there is an active running transaction.
-
getTransactionMode
-
beginTransaction
Begin transaction.- Parameters:
mode- transaction's mode.- Throws:
SqlJetException
-
commit
Commits transaction.- Throws:
SqlJetException
-
rollback
Rolls back transaction.- Throws:
SqlJetException
-
runEngineTransaction
protected Object runEngineTransaction(ISqlJetEngineTransaction op, SqlJetTransactionMode mode) throws SqlJetException Runs transaction.- Parameters:
op- transaction's body (closure).mode- transaction's mode.- Returns:
- result of
ISqlJetTransaction.run(org.tmatesoft.sqljet.core.table.SqlJetDb)call. - Throws:
SqlJetException
-