/** * Run read-only transaction. * * @param op transaction to run. * @return result of the {@link ISqlJetTransaction#run(SqlJetDb)} call. */ public Object runReadTransaction(ISqlJetTransaction op) throws SqlJetException { checkOpen(); return runTransaction(op, SqlJetTransactionMode.READ_ONLY); }
/** * Creates trigger from SQL clause. * * @param sql * CREATE TRIGGER ... sentence. * @return definition of the trigger being created. */ public ISqlJetTriggerDef createTrigger(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTriggerDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createTrigger(sql); } }); }
/** * Create index from SQL clause. * * @param sql * CREATE INDEX ... sentence. * @return definition of created index. */ public ISqlJetIndexDef createIndex(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetIndexDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createIndex(sql); } }); }
/** * Creates virtual table from SQL clause. * * @param sql * CREATE VIRTUAL TABLE ... sentence. * @return definition of create virtual table. */ public ISqlJetVirtualTableDef createVirtualTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetVirtualTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createVirtualTable(sql, 0); } }); }
/** * Drop table. * * @param tableName name of table to drop. */ public void dropTable(final String tableName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropTable(tableName); return null; } }); }
/** * Drop index. * * @param indexName name of the index to drop. */ public void dropIndex(final String indexName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropIndex(indexName); return null; } }); }
/** * Drop view. * * @param viewName name of the view to drop. */ public void dropView(final String viewName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropView(viewName); return null; } }); }
/** * Drop trigger. * * @param triggerName name of the trigger to drop. */ public void dropTrigger(final String triggerName) throws SqlJetException { checkOpen(); runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { getSchemaInternal().dropTrigger(triggerName); return null; } }); }
/** * Alters table. * * @param sql * ALTER TABLE ... sentence. * @return altered table schema definition. */ public ISqlJetTableDef alterTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().alterTable(sql); } }); }
/** * Creates view from SQL clause. * * @param sql * CREATE VIEW X AS SELECT ... sentence. * @return definition of the view being created. */ public ISqlJetViewDef createView(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetViewDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createView(sql); } }); }
/** * Create table from SQL clause. * * @param sql * CREATE TABLE ... sentence. * @return definition of create table. */ public ISqlJetTableDef createTable(final String sql) throws SqlJetException { checkOpen(); return (ISqlJetTableDef) runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { return getSchemaInternal().createTable(sql); } }); }
checkOpen(); return (SqlJetDb) runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException {
/** * Executes pragma statement. If statement queries pragma value then pragma * value will be returned. */ public Object pragma(final String sql) throws SqlJetException { checkOpen(); refreshSchema(); return runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { return new SqlJetPragmasHandler(getOptions()).pragma(sql); } }); }
/** * Run modifications in write transaction. * * @param op transaction to run. * @return result of the {@link ISqlJetTransaction#run(SqlJetDb)} call. */ public Object runWriteTransaction(ISqlJetTransaction op) throws SqlJetException { checkOpen(); if (writable) { return runTransaction(op, SqlJetTransactionMode.WRITE); } else { throw new SqlJetException(SqlJetErrorCode.MISUSE, "Can't start write transaction on read-only database"); } }
/** * Open table. * * @param tableName name of the table to open. * @return opened table */ public ISqlJetTable getTable(final String tableName) throws SqlJetException { checkOpen(); refreshSchema(); return (SqlJetTable) runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { return new SqlJetTable(db, btree, tableName, writable); } }); }