@Override public Connection openConnection(JDBCSchemaConfig factory) throws SQLException { Properties info = new Properties(); Optional.ofNullable(factory.getUsername()).map(value -> info.put("user", value)); Optional.ofNullable(factory.getPassword()).map(value -> info.put("password", value)); info.setProperty("socketTimeout", "120000"); info.setProperty("connectTimeout", "120000"); return new com.mysql.jdbc.Driver().connect(format("jdbc:mysql://%s:%s/%s", factory.getHost(), Optional.ofNullable(factory.getPort()).orElse(3306), factory.getDatabase()), info); } }, (jdbcSchemaConfig, table) -> checkCollection(jdbcSchemaConfig.getDatabase(), '`') + '.' + checkCollection(table, '`')),
@Override public Connection openConnection(JDBCSchemaConfig config) throws SQLException { Properties info = new Properties(); String userName = config.getUsername(); String password = config.getPassword(); Optional.ofNullable(userName).map(value -> info.put("user", value)); Optional.ofNullable(password).map(value -> info.put("password", value)); return new com.microsoft.sqlserver.jdbc.SQLServerDriver() .connect(format("jdbc:sqlserver://%s:%s;databaseName=%s", config.getHost(), Optional.ofNullable(config.getPort()).orElse(1433), config.getDatabase()), info); } }, (jdbcSchemaConfig, table) -> ofNullable(jdbcSchemaConfig.getSchema())
@Override public Connection openConnection(JDBCSchemaConfig factory) throws SQLException { Properties properties = new Properties(); Optional.ofNullable(factory.getPassword()) .ifPresent(pass -> properties.setProperty("password", pass)); Optional.ofNullable(factory.getUsername()) .ifPresent(user -> properties.setProperty("user", user)); properties.setProperty("loginTimeout", "120"); properties.setProperty("socketTimeout", "120"); properties.setProperty("connectTimeout", "120"); if (factory.getEnableSSL() != null) { properties.setProperty("ssl", factory.getEnableSSL().toString()); } return new org.postgresql.Driver().connect( format("jdbc:postgresql://%s:%s/%s", factory.getHost(), Optional.ofNullable(factory.getPort()).orElse(5432), factory.getDatabase()), properties); } }, (jdbcSchemaConfig, table) -> ofNullable(jdbcSchemaConfig.getSchema())