Ejemplo n.º 1
0
  /**
   * Method declaration
   *
   * @param compact
   * @throws SQLException
   */
  void close(boolean compact) throws SQLException {

    if (Trace.TRACE) {
      Trace.trace();
    }

    if (bReadOnly) {
      return;
    }

    // no more scripting
    closeScript();

    // create '.script.new' (for this the cache may be still required)
    writeScript(compact);

    // flush the cache (important: after writing the script)
    if (cCache != null) {
      cCache.flush();
    }

    closeAllTextCaches(compact);

    // create '.backup.new' using the '.data'
    backup();

    // we have the new files
    pProperties.setProperty("modified", "yes-new-files");
    pProperties.save();

    // old files can be removed and new files renamed
    renameNewToCurrent(sFileScript);
    renameNewToCurrent(sFileBackup);

    // now its done completely
    pProperties.setProperty("modified", "no");
    pProperties.setProperty("version", jdbcDriver.VERSION);
    pProperties.setProperty("hsqldb.compatible_version", "1.7.0");
    pProperties.save();
    pProperties.close();

    if (compact) {

      // stop the runner thread of this process (just for security)
      stop();

      // delete the .data so then a new file is created
      (new File(sFileCache)).delete();
      (new File(sFileBackup)).delete();

      // tony_lai@users 20020820
      // The database re-open and close has been moved to
      // Database#close(int closemode) for saving memory usage.
    }
  }
Ejemplo n.º 2
0
  /**
   * Method declaration
   *
   * @throws SQLException
   */
  void shutdown() throws SQLException {

    tRunner = null;

    if (cCache != null) {
      cCache.closeFile();

      cCache = null;
    }

    shutdownAllTextCaches();
    closeScript();
    pProperties.close();
  }
  /**
   * Method declaration
   *
   * @throws SQLException
   */
  public void save() throws SQLException {

    close();

    if (Trace.TRACE) {
      Trace.trace();
    }

    try {
      super.save();

      // after saving, open the file again
      load();
    } catch (Exception e) {
      throw Trace.error(Trace.FILE_IO_ERROR, fileName + ".properties " + e);
    }
  }
  /**
   * check by trying to delete the properties file this will not work if some application has the
   * file open this is why the properties file is kept open when running ;-) todo: check if this
   * works in all operating systems
   *
   * @return true if file is open
   * @exception java.sql.SQLException
   */
  protected boolean isFileOpen() throws java.sql.SQLException {

    close();

    if (Trace.TRACE) {
      Trace.trace();
    }

    if ((new File(fileName + ".properties")).delete() == false) {
      return true;
    }

    // the file was deleted, so recreate it now
    save();

    return false;
  }
  public void load() throws SQLException {

    close();

    if (Trace.TRACE) {
      Trace.trace();
    }

    try {
      File f = new File(fileName + ".properties");

      // the file is closed only when the database is closed
      propsFileStream = new FileInputStream(f);

      stringProps.load(propsFileStream);
    } catch (Exception e) {
      throw Trace.error(Trace.FILE_IO_ERROR, fileName + ".properties " + e);
    }
  }