protected SqlJetConnection(String fileName) throws SqlJetException { db = SqlJetDb.open(new File(fileName), false); }
/** * @param file * @param write * @param fsName * @return SqlJetDb object for opened database * @throws SqlJetException */ public static SqlJetDb open(File file, boolean write, final String fsName) throws SqlJetException { final SqlJetDb db = new SqlJetDb(file, write, fsName); db.open(); return db; }
/** * @param file * @param write * @param fs * @return SqlJetDb object for opened database * @throws SqlJetException */ public static SqlJetDb open(File file, boolean write, final ISqlJetFileSystem fs) throws SqlJetException { final SqlJetDb db = new SqlJetDb(file, write, fs); db.open(); return db; }
public Object runWithLock(SqlJetDb db) throws SqlJetException { if (temporaryDb == null || !temporaryDb.isOpen()) { closeTemporaryDatabase(); final File tmpDbFile = getTemporaryDatabaseFile(inMemory); if (tmpDbFile != null) { temporaryDb = SqlJetDb.open(tmpDbFile, true); } } return temporaryDb; }
public SqlJetDb open() { try { File dbFile = new File(dbPath); boolean noStructure = !dbFile.exists(); SqlJetDb db = SqlJetDb.open(dbFile, true); if (noStructure) { createStructure(db); } return db; } catch (Exception exception) { } return null; }
/** * <p> * 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. * <p> * * <p> * File could be null or have special value {@link #IN_MEMORY}. If file is * null then will be created temporary file which will be deleted at close. * If file is {@link #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. * </p> * * @param file * path to data base. Could be null or {@link #IN_MEMORY}. * @param write * open for writing if true. * @throws SqlJetException * if any trouble with access to file or database format. */ public static SqlJetDb open(File file, boolean write) throws SqlJetException { final SqlJetDb db = new SqlJetDb(file, write); db.open(); return db; }
/** * {@inheritDoc} * @see net.sf.hajdbc.pool.PoolProvider#create() */ @Override public synchronized SqlJetDb create() throws SqlJetException { boolean exists = this.file.exists(); SqlJetDb db = SqlJetDb.open(this.file, true); if (!exists) { db.getOptions().setAutovacuum(true); db.getOptions().setIncrementalVacuum(true); } return db; }
public static FSRepresentationCacheManager openRepresentationCache(FSFS fsfs) throws SVNException { final FSRepresentationCacheManager cacheObj = new FSRepresentationCacheManager(); try { cacheObj.myRepCacheDB = SqlJetDb.open(fsfs.getRepositoryCacheFile(), true); checkFormat(cacheObj.myRepCacheDB); cacheObj.myTable = cacheObj.myRepCacheDB.getTable(REP_CACHE_TABLE); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } return cacheObj; }
public static FSRepresentationCacheManager openRepresentationCache(FSFS fsfs) throws SVNException { final FSRepresentationCacheManager cacheObj = new FSRepresentationCacheManager(); try { cacheObj.myRepCacheDB = SqlJetDb.open(fsfs.getRepositoryCacheFile(), true); checkFormat(cacheObj.myRepCacheDB); cacheObj.myTable = cacheObj.myRepCacheDB.getTable(REP_CACHE_TABLE); } catch (SqlJetException e) { SVNErrorManager.error(convertError(e), SVNLogType.FSFS); } return cacheObj; }
public static void createRepresentationCache(File path) throws SVNException { SqlJetDb db = null; try { db = SqlJetDb.open(path, true); checkFormat(db); } catch (SqlJetException e) { SVNDebugLog.getDefaultLog().logError(SVNLogType.FSFS, e); } finally { if (db != null) { try { db.close(); } catch (SqlJetException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.FSFS, e); } } } }
public static void createRepresentationCache(File path) throws SVNException { SqlJetDb db = null; try { db = SqlJetDb.open(path, true); checkFormat(db); } catch (SqlJetException e) { SVNErrorManager.error(FSRepresentationCacheManager.convertError(e), SVNLogType.FSFS); } finally { if (db != null) { try { db.close(); } catch (SqlJetException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.FSFS, e); } } } }
public static void createRepresentationCache(File path) throws SVNException { SqlJetDb db = null; try { db = SqlJetDb.open(path, true); checkFormat(db); } catch (SqlJetException e) { SVNErrorManager.error(FSRepresentationCacheManager.convertError(e), SVNLogType.FSFS); } finally { if (db != null) { try { db.close(); } catch (SqlJetException e) { SVNDebugLog.getDefaultLog().logFine(SVNLogType.FSFS, e); } } } }
public static IFSRepresentationCacheManager openRepresentationCache(FSFS fsfs) throws SVNException { final FSRepresentationCacheManager cacheObj = new FSRepresentationCacheManager(); try { cacheObj.myRepCacheDB = SqlJetDb.open(fsfs.getRepositoryCacheFile(), true); cacheObj.myRepCacheDB.setSafetyLevel(SqlJetSafetyLevel.OFF); checkFormat(cacheObj.myRepCacheDB); cacheObj.myTable = cacheObj.myRepCacheDB.getTable(REP_CACHE_TABLE); } catch (SqlJetException e) { SVNDebugLog.getDefaultLog().logError(SVNLogType.FSFS, e); return new FSEmptyRepresentationCacheManager(); } return cacheObj; }
public static SVNSqlJetDb open(File sdbAbsPath, Mode mode, SqlJetPagerJournalMode journalMode, boolean temporaryDbInMemory) throws SVNException { if (mode != Mode.RWCreate) { if (!sdbAbsPath.exists()) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "File not found ''{0}''", sdbAbsPath); SVNErrorManager.error(err, SVNLogType.WC); } } if (journalMode == null) { journalMode = getJournalMode(); } try { SqlJetDb db = SqlJetDb.open(sdbAbsPath, mode != Mode.ReadOnly); db.setBusyHandler(DEFAULT_BUSY_HANDLER); db.setSafetyLevel(SqlJetSafetyLevel.OFF); db.setJournalMode(journalMode); return new SVNSqlJetDb(db, temporaryDbInMemory); } catch (SqlJetException e) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.SQLITE_ERROR, e); SVNErrorManager.error(err, SVNLogType.WC); return null; } }