public ISqlJetCursor open() throws SqlJetException { return (ISqlJetCursor) db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { return new SqlJetTableDataCursor(new SqlJetBtreeDataTable(btree, tableName, write), db); } }); }
public ISqlJetCursor order(final String indexName) throws SqlJetException { return (ISqlJetCursor) db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { final SqlJetBtreeDataTable table = new SqlJetBtreeDataTable(btree, tableName, write); checkIndexName(indexName, table); return new SqlJetIndexOrderCursor(table, db, indexName); } }); }
private static void checkFormat(final SqlJetDb db) throws SqlJetException { db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } }); }
public void exec(final String sql, final SqlJetExecCallback callback) throws SqlJetException { db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { SqlJetPreparedStatement stmt = prepare(sql); try { while (stmt.step()) { if (callback != null) { callback.processRow(stmt); } } } finally { stmt.close(); } return null; } }); }
private static void checkFormat(final SqlJetDb db) throws SqlJetException { db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } }); }
private static void checkFormat(final SqlJetDb db) throws SqlJetException { db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { int version = db.getOptions().getUserVersion(); if (version < REP_CACHE_DB_FORMAT) { db.getOptions().setAutovacuum(true); db.runWriteTransaction(new ISqlJetTransaction() { public Object run(SqlJetDb db) throws SqlJetException { db.getOptions().setUserVersion(REP_CACHE_DB_FORMAT); db.createTable(FSRepresentationCacheManager.REP_CACHE_DB_SQL); return null; } }); } else if (version > REP_CACHE_DB_FORMAT) { throw new SqlJetException("Schema format " + version + " not recognized"); } return null; } }); }
public ISqlJetCursor lookup(final String indexName, final Object... key) throws SqlJetException { final Object[] k = SqlJetUtility.adjustNumberTypes(key); return (ISqlJetCursor) db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { final SqlJetBtreeDataTable table = new SqlJetBtreeDataTable(btree, tableName, write); checkIndexName(indexName, table); return new SqlJetIndexScopeCursor(table, db, indexName, k, k); } }); }
public ISqlJetCursor scope(final String indexName, SqlJetScope scope) throws SqlJetException { final SqlJetScope adjustedScope = SqlJetUtility.adjustScopeNumberTypes(scope); return (ISqlJetCursor) db.runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { final SqlJetBtreeDataTable table = new SqlJetBtreeDataTable(btree, tableName, write); checkIndexName(indexName, table); if (isNeedReverse(getIndexTable(indexName, table), adjustedScope)) { return new SqlJetReverseOrderCursor(new SqlJetIndexScopeCursor(table, db, indexName, adjustedScope.reverse())); } else { return new SqlJetIndexScopeCursor(table, db, indexName, adjustedScope); } } }); }
return (SqlJetDb) runWithLock(new ISqlJetRunnableWithLock() { public Object runWithLock(SqlJetDb db) throws SqlJetException { if (temporaryDb == null || !temporaryDb.isOpen()) {
/** * 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); } }); }
/** * 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); } }); }