@Test public void testParseURL() throws IoTDBURLException { String userName = "test"; String userPwd = "test"; String host = "localhost"; int port = 6667; Properties properties = new Properties(); properties.setProperty(Config.AUTH_USER, userName); properties.setProperty(Config.AUTH_PASSWORD, userPwd); IoTDBConnectionParams params = Utils .parseUrl(String.format(Config.IOTDB_URL_PREFIX + "%s:%s/", host, port), properties); assertEquals(params.getHost(), host); assertEquals(params.getPort(), port); assertEquals(params.getUsername(), userName); assertEquals(params.getPassword(), userPwd); }
public static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); Matcher matcher = pattern.matcher(url.substring(Config.IOTDB_URL_PREFIX.length())); boolean isUrlLegal = false; while (matcher.find()) { params.setHost(matcher.group(1)); params.setPort(Integer.parseInt((matcher.group(2)))); isUrlLegal = true; } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }
Utils { public static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); Matcher matcher = pattern.matcher(url.substring(Config.IOTDB_URL_PREFIX.length())); boolean isUrlLegal = false; while (matcher.find()) { params.setHost(matcher.group(1)); params.setPort(Integer.parseInt((matcher.group(2)))); isUrlLegal = true; } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; } }
Utils { public static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); Matcher matcher = pattern.matcher(url.substring(Config.IOTDB_URL_PREFIX.length())); boolean isUrlLegal = false; while (matcher.find()) { params.setHost(matcher.group(1)); params.setPort(Integer.parseInt((matcher.group(2)))); isUrlLegal = true; } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }  }
Utils { public static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); Matcher matcher = pattern.matcher(url.substring(Config.IOTDB_URL_PREFIX.length())); boolean isUrlLegal = false; while (matcher.find()) { params.setHost(matcher.group(1)); params.setPort(Integer.parseInt((matcher.group(2)))); isUrlLegal = true; } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }  static IoTDBConnectionParams parseUrl(String url, Properties info); static void verifySuccess(TS_Status status); static List<RowRecord> convertRowRecords(TSQueryDataSet tsQueryDataSet); }
Utils { public static IoTDBConnectionParams parseUrl(String url, Properties info) throws IoTDBURLException { IoTDBConnectionParams params = new IoTDBConnectionParams(url); if (url.trim().equalsIgnoreCase(Config.IOTDB_URL_PREFIX)) { return params; } Pattern pattern = Pattern.compile("([^;]*):([^;]*)/"); Matcher matcher = pattern.matcher(url.substring(Config.IOTDB_URL_PREFIX.length())); boolean isUrlLegal = false; while (matcher.find()) { params.setHost(matcher.group(1)); params.setPort(Integer.parseInt((matcher.group(2)))); isUrlLegal = true; } if (!isUrlLegal) { throw new IoTDBURLException("Error url format, url should be jdbc:iotdb: } if (info.containsKey(Config.AUTH_USER)) { params.setUsername(info.getProperty(Config.AUTH_USER)); } if (info.containsKey(Config.AUTH_PASSWORD)) { params.setPassword(info.getProperty(Config.AUTH_PASSWORD)); } return params; }  static IoTDBConnectionParams parseUrl(String url, Properties info); static void verifySuccess(TS_Status status); static List<RowRecord> convertRowRecords(TSQueryDataSet tsQueryDataSet);  }