コード例 #1
0
  /**
   * 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() {

    boolean isNew = false;

    setState(DATABASE_OPENING);

    try {
      nameManager = new HsqlNameManager(this);
      granteeManager = new GranteeManager(this);
      userManager = new UserManager(this);
      schemaManager = new SchemaManager(this);
      persistentStoreCollection = new PersistentStoreCollectionDatabase(this);
      isReferentialIntegrity = true;
      sessionManager = new SessionManager(this);
      collation = collation.newDatabaseInstance();
      dbInfo = DatabaseInformation.newDatabaseInformation(this);
      txManager = new TransactionManager2PL(this);

      lobManager.createSchema();
      sessionManager.getSysLobSession().setSchema(SqlInvariants.LOBS_SCHEMA);
      schemaManager.setSchemaChangeTimestamp();
      schemaManager.createSystemTables();

      // completed metadata
      logger.open();

      isNew = logger.isNewDatabase;

      if (isNew) {
        String username = urlProperties.getProperty("user", "SA");
        String password = urlProperties.getProperty("password", "");

        userManager.createFirstUser(username, password);
        schemaManager.createPublicSchema();
        logger.checkpoint(false);
      }

      lobManager.open();
      dbInfo.setWithContent(true);

      checkpointRunner = new CheckpointRunner();
      timeoutRunner = new TimeoutRunner();
    } catch (Throwable e) {
      logger.close(Database.CLOSEMODE_IMMEDIATELY);
      logger.releaseLock();
      setState(DATABASE_SHUTDOWN);
      clearStructures();
      DatabaseManager.removeDatabase(this);

      if (!(e instanceof HsqlException)) {
        e = Error.error(ErrorCode.GENERAL_ERROR, e);
      }

      logger.logSevereEvent("could not reopen database", e);

      throw (HsqlException) e;
    }

    setState(DATABASE_ONLINE);
  }
コード例 #2
0
  /**
   * 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() {

    boolean isNew = false;

    setState(DATABASE_OPENING);

    try {
      nameManager = new HsqlNameManager(this);
      granteeManager = new GranteeManager(this);
      userManager = new UserManager(this);
      schemaManager = new SchemaManager(this);
      persistentStoreCollection = new PersistentStoreCollectionDatabase();
      isReferentialIntegrity = true;
      sessionManager = new SessionManager(this);
      collation = collation.getDefaultInstance();
      dbInfo = DatabaseInformation.newDatabaseInformation(this);
      txManager = new TransactionManager2PL(this);

      lobManager.createSchema();
      logger.openPersistence();

      isNew = logger.isNewDatabase;

      if (isNew) {
        userManager.createSAUser();
        schemaManager.createPublicSchema();
        lobManager.initialiseLobSpace();
        logger.checkpoint(false);
      }

      lobManager.open();
      dbInfo.setWithContent(true);
    } catch (Throwable e) {
      logger.closePersistence(Database.CLOSEMODE_IMMEDIATELY);
      logger.releaseLock();
      setState(DATABASE_SHUTDOWN);
      clearStructures();
      DatabaseManager.removeDatabase(this);

      if (!(e instanceof HsqlException)) {
        e = Error.error(ErrorCode.GENERAL_ERROR, e);
      }

      logger.logSevereEvent("could not reopen database", e);

      throw (HsqlException) e;
    }

    setState(DATABASE_ONLINE);
  }
コード例 #3
0
  /**
   * Ensures system table producer's table cache, if it exists, is set dirty. After this call
   * up-to-date versions are generated in response to system table requests.
   *
   * <p>Also resets all prepared statements if a change to database structure can possibly affect
   * any existing prepared statement's validity.
   *
   * <p>The argument is false if the change to the database structure does not affect the prepared
   * statement, such as when a new table is added.
   *
   * <p>The argument is typically true when a database object is dropped, altered or a permission
   * was revoked.
   *
   * @param resetPrepared If true, reset all prepared statements.
   */
  public void setMetaDirty(boolean resetPrepared) {

    if (dbInfo != null) {
      dbInfo.setDirty();
    }
  }