diff --git a/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java b/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java index 7c7c855d9..dda0270ab 100644 --- a/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java +++ b/src/main/java/com/zendesk/maxwell/bootstrap/MaxwellBootstrapUtilityConfig.java @@ -36,16 +36,8 @@ public MaxwellBootstrapUtilityConfig(String argv[]) { public String getConnectionURI() { - URIBuilder uriBuilder = new URIBuilder(); - uriBuilder.setScheme("jdbc:mysql"); - uriBuilder.setHost(mysql.host); - uriBuilder.setPort(mysql.port); - uriBuilder.setPath("/" + schemaDatabaseName); - for (Map.Entry jdbcOption : mysql.jdbcOptions.entrySet()) { - uriBuilder.addParameter(jdbcOption.getKey(), jdbcOption.getValue()); - } try { - return uriBuilder.build().toString(); + return getConfigConnectionURI(mysql); } catch (URISyntaxException e) { LOGGER.error(e.getMessage(), e); throw new RuntimeException("Unable to generate bootstrap's jdbc connection URI", e); @@ -53,7 +45,24 @@ public String getConnectionURI() { } public String getReplicationConnectionURI( ) { - return "jdbc:mysql://" + replicationMysql.host + ":" + replicationMysql.port; + try { + return getConfigConnectionURI(replicationMysql); + } catch (URISyntaxException e) { + LOGGER.error(e.getMessage(), e); + throw new RuntimeException("Unable to generate bootstrap's replication jdbc connection URI", e); + } + } + + private String getConfigConnectionURI(MaxwellMysqlConfig config) throws URISyntaxException { + URIBuilder uriBuilder = new URIBuilder(); + uriBuilder.setScheme("jdbc:mysql"); + uriBuilder.setHost(config.host); + uriBuilder.setPort(config.port); + uriBuilder.setPath("/" + schemaDatabaseName); + for (Map.Entry jdbcOption : config.jdbcOptions.entrySet()) { + uriBuilder.addParameter(jdbcOption.getKey(), jdbcOption.getValue()); + } + return uriBuilder.build().toString(); } protected OptionParser buildOptionParser() {