/** * Opens this database. The database should be opened after construction. or reopened by the * close(int closemode) method during a "shutdown compact". Closes the log if there is an error. */ void reopen() throws HsqlException { boolean isNew; setState(DATABASE_OPENING); try { databaseProperties = new HsqlDatabaseProperties(this); isNew = !DatabaseURL.isFileBasedDatabaseType(sType) || !databaseProperties.checkFileExists(); if (isNew && urlProperties.isPropertyTrue("ifexists")) { throw Trace.error(Trace.DATABASE_NOT_EXISTS, sName); } databaseProperties.load(); databaseProperties.setURLProperties(urlProperties); compiledStatementManager.reset(); nameManager = new HsqlNameManager(); granteeManager = new GranteeManager(this); userManager = new UserManager(this); hAlias = Library.getAliasMap(); schemaManager = new SchemaManager(this); bReferentialIntegrity = true; sessionManager = new SessionManager(this); txManager = new TransactionManager(this); collation = new Collation(); dbInfo = DatabaseInformation.newDatabaseInformation(this); databaseProperties.setDatabaseVariables(); if (DatabaseURL.isFileBasedDatabaseType(sType)) { logger.openLog(this); } if (isNew) { sessionManager .getSysSession() .sqlExecuteDirectNoPreChecks("CREATE USER SA PASSWORD \"\" ADMIN"); logger.synchLogForce(); } dbInfo.setWithContent(true); } catch (Throwable e) { logger.closeLog(Database.CLOSEMODE_IMMEDIATELY); logger.releaseLock(); setState(DATABASE_SHUTDOWN); clearStructures(); DatabaseManager.removeDatabase(this); if (!(e instanceof HsqlException)) { e = Trace.error(Trace.GENERAL_ERROR, e.toString()); } throw (HsqlException) e; } setState(DATABASE_ONLINE); }
/** * Opens this database. The database should be opened after construction. or reopened by the * close(int closemode) method during a "shutdown compact". Closes the log if there is an error. */ void reopen() throws HsqlException { setState(DATABASE_OPENING); try { User sysUser; isNew = (sType == DatabaseManager.S_MEM || !HsqlProperties.checkFileExists(sPath, isFilesInJar(), getClass())); databaseProperties = new HsqlDatabaseProperties(this); databaseProperties.load(); databaseProperties.setURLProperties(urlProperties); compiledStatementManager.reset(); tTable = new HsqlArrayList(); userManager = new UserManager(); hAlias = Library.getAliasMap(); nameManager = new HsqlNameManager(); triggerNameList = new DatabaseObjectNames(); indexNameList = new DatabaseObjectNames(); constraintNameList = new DatabaseObjectNames(); sequenceManager = new SequenceManager(); bReferentialIntegrity = true; sysUser = userManager.createSysUser(this); sessionManager = new SessionManager(this, sysUser); dInfo = DatabaseInformation.newDatabaseInformation(this); if (sType != DatabaseManager.S_MEM) { logger.openLog(this); } if (isNew) { sessionManager .getSysSession() .sqlExecuteDirectNoPreChecks("CREATE USER SA PASSWORD \"\" ADMIN"); } dInfo.setWithContent(true); } catch (Throwable e) { logger.closeLog(Database.CLOSEMODE_IMMEDIATELY); logger.releaseLock(); setState(DATABASE_SHUTDOWN); clearStructures(); if (!(e instanceof HsqlException)) { e = Trace.error(Trace.GENERAL_ERROR, e.toString()); } throw (HsqlException) e; } setState(DATABASE_ONLINE); }