/** * 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; } }
/** * Create a connection info object. * * @param name the database name (including tags), but without the "jdbc:h2:" prefix */ public ConnectionInfo(String name) { this.name = name; this.url = Constants.START_URL + name; // 如jdbc:h2:mydb,没有tcp了,此时persistent也是true parseName(); }