Class SqlJetEngine
java.lang.Object
org.tmatesoft.sqljet.core.table.engine.SqlJetEngine
- Direct Known Subclasses:
SqlJetDb
,SqlJetMapDb
public class SqlJetEngine
extends java.lang.Object
- Author:
- TMate Software Ltd., Sergey Scherbina (sergey.scherbina@gmail.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ISqlJetBtree
protected ISqlJetDbHandle
protected java.io.File
protected static final ISqlJetFileSystemsManager
protected ISqlJetFileSystem
protected boolean
protected boolean
-
Constructor Summary
ConstructorsConstructorDescriptionSqlJetEngine
(java.io.File file, boolean writable) SqlJetEngine
(java.io.File file, boolean writable, java.lang.String fsName) SqlJetEngine
(java.io.File file, boolean writable, ISqlJetFileSystem fs) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Begin transaction.protected void
void
close()
Close connection to database.protected void
void
commit()
Commits transaction.protected void
finalize()
Get busy handler.int
Get cache size (in count of pages).java.io.File
getFile()
Get jounrnal modegetMutex()
Retruns threading synchronization mutex.Returns database options.Get safety levelprotected SqlJetSchema
boolean
Returns true if a transaction is active.boolean
isOpen()
Checks is database open.boolean
Check write access to data base.void
open()
Opens connection to database.protected void
Reads database schema and options.void
Refreshes database schema.void
registerFileSystem
(ISqlJetFileSystem fs, boolean isDefault) void
rollback()
Rolls back transaction.protected java.lang.Object
Runs transaction.java.lang.Object
void
setBusyHandler
(ISqlJetBusyHandler busyHandler) Set busy handler.void
setCacheSize
(int cacheSize) Set cache size (in count of pages).void
setJournalMode
(SqlJetPagerJournalMode journalMode) Set journal modevoid
setSafetyLevel
(SqlJetSafetyLevel safetyLevel) Set safety levelvoid
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
FILE_SYSTEM_MANAGER
-
fileSystem
-
writable
protected boolean writable -
dbHandle
-
btree
-
open
protected boolean open -
file
protected java.io.File file
-
-
Constructor Details
-
SqlJetEngine
public SqlJetEngine(java.io.File file, boolean writable) -
SqlJetEngine
- Parameters:
file
-writable
-fs
-
-
SqlJetEngine
public SqlJetEngine(java.io.File file, boolean writable, java.lang.String fsName) throws SqlJetException - Parameters:
file
-writable
-fsName
-- Throws:
SqlJetException
-
-
Method Details
-
registerFileSystem
- Parameters:
fs
-isDefault
-- Throws:
SqlJetException
-
unregisterFileSystem
- Parameters:
fs
-- Throws:
SqlJetException
-
getFile
public java.io.File 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
protected void finalize() throws java.lang.Throwable- Overrides:
finalize
in classjava.lang.Object
- Throws:
java.lang.Throwable
-
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 java.lang.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
-