|
SQLJet Home | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.tmatesoft.sqljet.core.table.SqlJetDb
public class SqlJetDb
Connection to database. This class currently is main entry point in SQLJet API.
It allows to perform next tasks:
Field Summary | |
---|---|
static java.io.File |
IN_MEMORY
File name for in memory database. |
Constructor Summary | |
---|---|
SqlJetDb(java.io.File file,
boolean writable)
Creates connection to database but not open it. |
Method Summary | |
---|---|
ISqlJetTableDef |
alterTable(java.lang.String sql)
Alters table. |
void |
beginTransaction(SqlJetTransactionMode mode)
Begin transaction. |
void |
beginTransaction(org.tmatesoft.sqljet.core.internal.SqlJetTransactionMode mode)
Deprecated. use { beginTransaction(SqlJetTransactionMode) instead. |
void |
close()
Close connection to database. |
void |
commit()
Commit transaction. |
ISqlJetIndexDef |
createIndex(java.lang.String sql)
Create index from SQL clause. |
ISqlJetTableDef |
createTable(java.lang.String sql)
Create table from SQL clause. |
ISqlJetVirtualTableDef |
createVirtualTable(java.lang.String sql)
Create virtual table from SQL clause. |
void |
dropIndex(java.lang.String indexName)
Drop index. |
void |
dropTable(java.lang.String tableName)
Drop table. |
protected void |
finalize()
|
ISqlJetBusyHandler |
getBusyHandler()
Get busy handler. |
int |
getCacheSize()
Get cache size (in count of pages). |
java.io.File |
getFile()
|
ISqlJetMutex |
getMutex()
Get threading synchronization mutex. |
ISqlJetOptions |
getOptions()
Get database options. |
ISqlJetSchema |
getSchema()
Get database schema. |
ISqlJetTable |
getTable(java.lang.String tableName)
Open table. |
SqlJetTransactionMode |
getTransactionMode()
|
boolean |
isInTransaction()
Return true if a transaction is active. |
boolean |
isOpen()
Checks is database open. |
boolean |
isWritable()
Check write access to data base. |
void |
open()
Opens connection to database. |
static SqlJetDb |
open(java.io.File file,
boolean write)
Opens connection to data base. |
java.lang.Object |
pragma(java.lang.String sql)
Executes pragma statement. |
void |
refreshSchema()
Refresh database schema. |
void |
rollback()
Rollback transaction. |
java.lang.Object |
runReadTransaction(ISqlJetTransaction op)
Run read-only transaction. |
java.lang.Object |
runTransaction(ISqlJetTransaction op,
SqlJetTransactionMode mode)
Run transaction. |
java.lang.Object |
runTransaction(ISqlJetTransaction op,
org.tmatesoft.sqljet.core.internal.SqlJetTransactionMode mode)
Deprecated. use runTransaction(ISqlJetTransaction, SqlJetTransactionMode) |
java.lang.Object |
runWithLock(ISqlJetRunnableWithLock op)
Do some actions with locking database's internal threads synchronization mutex. |
java.lang.Object |
runWriteTransaction(ISqlJetTransaction op)
Run modifications in write transaction. |
void |
setBusyHandler(ISqlJetBusyHandler busyHandler)
Set busy handler. |
void |
setCacheSize(int cacheSize)
Set cache size (in count of pages). |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.io.File IN_MEMORY
Constructor Detail |
---|
public SqlJetDb(java.io.File file, boolean writable)
Creates connection to database but not open it. Doesn't open database
file until not called method open()
.
File could be null or have special value IN_MEMORY
. If file is
null then will be created temporary file which will be deleted at close.
If file is IN_MEMORY
then file doesn't created and instead
database will placed in memory. If regular file is specified but doesn't
exist then it will be tried to created.
file
- path to data base. Could be null or IN_MEMORY
.writable
- if true then will allow data modification.Method Detail |
---|
public void open() throws SqlJetException
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.
SqlJetException
- if any trouble with access to file or database format.public static SqlJetDb open(java.io.File file, boolean write) throws SqlJetException
Opens connection to data base. 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.
File could be null or have special value IN_MEMORY
. If file is
null then will be created temporary file which will be deleted at close.
If file is IN_MEMORY
then file doesn't created and instead
database will placed in memory. If regular file is specified but doesn't
exist then it will be tried to created.
file
- path to data base. Could be null or IN_MEMORY
.write
- open for writing if true.
SqlJetException
- if any trouble with access to file or database format.public boolean isOpen()
public void close() throws SqlJetException
SqlJetException
- it is possible to get exception if there is actvie
transaction and rollback did not success.protected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
public void setCacheSize(int cacheSize) throws SqlJetException
cacheSize
- the count of pages which can hold cache.
SqlJetException
public int getCacheSize() throws SqlJetException
SqlJetException
public java.lang.Object runWithLock(ISqlJetRunnableWithLock op) throws SqlJetException
op
- operation to run
ISqlJetRunnableWithLock.runWithLock(SqlJetDb)
call.
SqlJetException
- in case operation fails to run.public java.io.File getFile()
public boolean isWritable() throws SqlJetException
SqlJetException
public ISqlJetSchema getSchema() throws SqlJetException
SqlJetException
public ISqlJetTable getTable(java.lang.String tableName) throws SqlJetException
tableName
- name of the table to open.
SqlJetException
public java.lang.Object runWriteTransaction(ISqlJetTransaction op) throws SqlJetException
op
- transaction to run.
ISqlJetTransaction.run(SqlJetDb)
call.
SqlJetException
public java.lang.Object runReadTransaction(ISqlJetTransaction op) throws SqlJetException
op
- transaction to run.
ISqlJetTransaction.run(SqlJetDb)
call.
SqlJetException
public java.lang.Object runTransaction(ISqlJetTransaction op, SqlJetTransactionMode mode) throws SqlJetException
op
- transaction's body (closure).mode
- transaction's mode.
ISqlJetTransaction.run(SqlJetDb)
call.
SqlJetException
public java.lang.Object runTransaction(ISqlJetTransaction op, org.tmatesoft.sqljet.core.internal.SqlJetTransactionMode mode) throws SqlJetException
runTransaction(ISqlJetTransaction, SqlJetTransactionMode)
SqlJetException
public void beginTransaction(SqlJetTransactionMode mode) throws SqlJetException
mode
- transaction's mode.
SqlJetException
public void beginTransaction(org.tmatesoft.sqljet.core.internal.SqlJetTransactionMode mode) throws SqlJetException
beginTransaction(SqlJetTransactionMode)
instead.
SqlJetException
public void commit() throws SqlJetException
SqlJetException
public void rollback() throws SqlJetException
SqlJetException
public ISqlJetOptions getOptions() throws SqlJetException
SqlJetException
public java.lang.Object pragma(java.lang.String sql) throws SqlJetException
SqlJetException
public ISqlJetTableDef createTable(java.lang.String sql) throws SqlJetException
sql
- CREATE TABLE ... sentence.
SqlJetException
public ISqlJetIndexDef createIndex(java.lang.String sql) throws SqlJetException
sql
- CREATE INDEX ... sentence.
SqlJetException
public void dropTable(java.lang.String tableName) throws SqlJetException
tableName
- name of table to drop.
SqlJetException
public void dropIndex(java.lang.String indexName) throws SqlJetException
indexName
- name of the index to drop.
SqlJetException
public ISqlJetTableDef alterTable(java.lang.String sql) throws SqlJetException
sql
- ALTER TABLE ... sentence.
SqlJetException
public ISqlJetVirtualTableDef createVirtualTable(java.lang.String sql) throws SqlJetException
sql
- CREATE VIRTUAL TABLE ... sentence.
SqlJetException
public ISqlJetBusyHandler getBusyHandler()
public void setBusyHandler(ISqlJetBusyHandler busyHandler)
busyHandler
- the busy handler.public void refreshSchema() throws SqlJetException
SqlJetException
public boolean isInTransaction()
public SqlJetTransactionMode getTransactionMode()
public ISqlJetMutex getMutex()
|
SQLJet Home | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |