Пример #1
0
  /**
   * Create a connection info object.
   *
   * @param u the database URL (must start with jdbc:h2:)
   * @param info the connection properties
   */
  public ConnectionInfo(String u, Properties info) {
    u = remapURL(u);
    this.originalURL = u; // originalURL不会再变
    if (!u.startsWith(Constants.START_URL)) { // "jdbc:h2:"
      throw DbException.getInvalidValueException("url", u);
    }
    this.url = u; // url在接下来的代码中会再变,去掉参数
    readProperties(info);
    readSettingsFromURL();
    setUserName(removeProperty("USER", ""));
    convertPasswords();

    // 去掉"jdbc:h2:",比如jdbc:h2:tcp://localhost:9092/test9
    // name = tcp://localhost:9092/test9
    name = url.substring(Constants.START_URL.length());
    parseName();
    String recoverTest = removeProperty("RECOVER_TEST", null);
    if (recoverTest != null) {
      FilePathRec.register();
      try {
        Utils.callStaticMethod("org.h2.store.RecoverTester.init", recoverTest);
      } catch (Exception e) {
        throw DbException.convert(e);
      }
      name = "rec:" + name;
    }
  }