org.tmatesoft.sqljet.core.table.engine
Class SqlJetEngine
- java.lang.Object
-
- org.tmatesoft.sqljet.core.table.engine.SqlJetEngine
-
- Direct Known Subclasses:
- SqlJetDb, SqlJetMapDb
public class SqlJetEngine extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor and Description SqlJetEngine(java.io.File file, boolean writable)SqlJetEngine(java.io.File file, boolean writable, ISqlJetFileSystem fs)SqlJetEngine(java.io.File file, boolean writable, java.lang.String fsName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbeginTransaction(SqlJetTransactionMode mode)Begin transaction.voidclose()Close connection to database.voidcommit()Commits transaction.ISqlJetBusyHandlergetBusyHandler()Get busy handler.intgetCacheSize()Get cache size (in count of pages).java.io.FilegetFile()ISqlJetFileSystemgetFileSystem()SqlJetPagerJournalModegetJournalMode()Get jounrnal modeISqlJetMutexgetMutex()Retruns threading synchronization mutex.ISqlJetOptionsgetOptions()Returns database options.SqlJetSafetyLevelgetSafetyLevel()Get safety levelSqlJetTransactionModegetTransactionMode()booleanisInTransaction()Returns true if a transaction is active.booleanisOpen()Checks is database open.booleanisWritable()Check write access to data base.voidopen()Opens connection to database.voidrefreshSchema()Refreshes database schema.voidregisterFileSystem(ISqlJetFileSystem fs, boolean isDefault)voidrollback()Rolls back transaction.java.lang.ObjectrunSynchronized(ISqlJetEngineSynchronized op)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 levelvoidunregisterFileSystem(ISqlJetFileSystem fs)
-
-
-
Constructor Detail
-
SqlJetEngine
public SqlJetEngine(java.io.File file, boolean writable)
-
SqlJetEngine
public SqlJetEngine(java.io.File file, boolean writable, ISqlJetFileSystem fs)- 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 Detail
-
registerFileSystem
public void registerFileSystem(ISqlJetFileSystem fs, boolean isDefault) throws SqlJetException
- Parameters:
fs-isDefault-- Throws:
SqlJetException
-
unregisterFileSystem
public void unregisterFileSystem(ISqlJetFileSystem fs) throws SqlJetException
- Parameters:
fs-- Throws:
SqlJetException
-
getFile
public java.io.File getFile()
- Returns:
- database file this engine is created for.
-
isWritable
public boolean isWritable() throws SqlJetExceptionCheck write access to data base.- Returns:
- true if modification is allowed
- Throws:
SqlJetException
-
getFileSystem
public ISqlJetFileSystem getFileSystem()
-
isOpen
public boolean isOpen()
Checks is database open.- Returns:
- true if database is open.
-
open
public void open() throws SqlJetExceptionOpens 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
public java.lang.Object runSynchronized(ISqlJetEngineSynchronized op) throws SqlJetException
- Throws:
SqlJetException
-
close
public void close() throws SqlJetExceptionClose 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.
-
getOptions
public ISqlJetOptions getOptions() throws SqlJetException
Returns database options.- Returns:
- options of this database.
- Throws:
SqlJetException
-
refreshSchema
public void refreshSchema() throws SqlJetExceptionRefreshes database schema.- Throws:
SqlJetException
-
getBusyHandler
public ISqlJetBusyHandler getBusyHandler()
Get busy handler.- Returns:
- the busy handler.
-
setBusyHandler
public void setBusyHandler(ISqlJetBusyHandler busyHandler)
Set busy handler. Busy handler treats situation when database is locked by other process or thread.- Parameters:
busyHandler- the busy handler.
-
getMutex
public ISqlJetMutex getMutex()
Retruns threading synchronization mutex.- Returns:
- Semaphore instance used to synchronize database access from multiple threads within the same process.
-
setCacheSize
public void setCacheSize(int cacheSize) throws SqlJetExceptionSet cache size (in count of pages).- Parameters:
cacheSize- the count of pages which can hold cache.- Throws:
SqlJetException
-
getCacheSize
public int getCacheSize() throws SqlJetExceptionGet cache size (in count of pages).- Returns:
- the count of pages which can hold cache.
- Throws:
SqlJetException
-
setSafetyLevel
public void setSafetyLevel(SqlJetSafetyLevel safetyLevel) throws SqlJetException
Set safety level- Parameters:
safetyLevel-- Throws:
SqlJetException
-
setJournalMode
public void setJournalMode(SqlJetPagerJournalMode journalMode) throws SqlJetException
Set journal mode- Parameters:
journalMode-- Throws:
SqlJetException
-
getSafetyLevel
public SqlJetSafetyLevel getSafetyLevel() throws SqlJetException
Get safety level- Returns:
- the safety level set.
- Throws:
SqlJetException
-
getJournalMode
public SqlJetPagerJournalMode getJournalMode() throws SqlJetException
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
public SqlJetTransactionMode getTransactionMode()
-
beginTransaction
public void beginTransaction(SqlJetTransactionMode mode) throws SqlJetException
Begin transaction.- Parameters:
mode- transaction's mode.- Throws:
SqlJetException
-
commit
public void commit() throws SqlJetExceptionCommits transaction.- Throws:
SqlJetException
-
rollback
public void rollback() throws SqlJetExceptionRolls back transaction.- Throws:
SqlJetException
-
-
DataMelt 3.0 © DataMelt by jWork.ORG