From 697821738cae042db6fcb10f47c4bae819d173ac Mon Sep 17 00:00:00 2001 From: Alexandre Girard Date: Tue, 22 Feb 2022 15:10:09 -0800 Subject: [PATCH] Pass string --- .../main/java/io/airbyte/db/Databases.java | 28 +++++++++++++++++++ ...RedshiftCopyDestinationAcceptanceTest.java | 4 +-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/airbyte-db/lib/src/main/java/io/airbyte/db/Databases.java b/airbyte-db/lib/src/main/java/io/airbyte/db/Databases.java index 3fb65f85f73b..effde679dd72 100644 --- a/airbyte-db/lib/src/main/java/io/airbyte/db/Databases.java +++ b/airbyte-db/lib/src/main/java/io/airbyte/db/Databases.java @@ -138,6 +138,18 @@ public static Database createDatabase(final String username, return new Database(connectionPool, dialect); } + public static Database createDatabase(final String username, + final String password, + final String jdbcConnectionString, + final String driverClassName, + final SQLDialect dialect, + final String connectionProperties) { + final BasicDataSource connectionPool = + createBasicDataSource(username, password, jdbcConnectionString, driverClassName, connectionProperties); + + return new Database(connectionPool, dialect); + } + public static JdbcDatabase createJdbcDatabase(final String username, final String password, final String jdbcConnectionString, @@ -213,6 +225,22 @@ public static BasicDataSource createBasicDataSource(final String username, return connectionPool; } + public static BasicDataSource createBasicDataSource(final String username, + final String password, + final String jdbcConnectionString, + final String driverClassName, + final String connectionProperties) { + final BasicDataSource connectionPool = new BasicDataSource(); + connectionPool.setDriverClassName(driverClassName); + connectionPool.setUsername(username); + connectionPool.setPassword(password); + connectionPool.setInitialSize(0); + connectionPool.setMaxTotal(5); + connectionPool.setUrl(jdbcConnectionString); + connectionPool.setConnectionProperties(connectionProperties); + return connectionPool; + } + public static BigQueryDatabase createBigQueryDatabase(final String projectId, final String jsonCreds) { return new BigQueryDatabase(projectId, jsonCreds); } diff --git a/airbyte-integrations/connectors/destination-redshift/src/test-integration/java/io/airbyte/integrations/destination/redshift/RedshiftCopyDestinationAcceptanceTest.java b/airbyte-integrations/connectors/destination-redshift/src/test-integration/java/io/airbyte/integrations/destination/redshift/RedshiftCopyDestinationAcceptanceTest.java index 4610da6999a6..d9a1fae6a06c 100644 --- a/airbyte-integrations/connectors/destination-redshift/src/test-integration/java/io/airbyte/integrations/destination/redshift/RedshiftCopyDestinationAcceptanceTest.java +++ b/airbyte-integrations/connectors/destination-redshift/src/test-integration/java/io/airbyte/integrations/destination/redshift/RedshiftCopyDestinationAcceptanceTest.java @@ -6,7 +6,6 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import com.google.common.collect.ImmutableMap; import io.airbyte.commons.io.IOs; import io.airbyte.commons.json.Jsons; import io.airbyte.commons.string.Strings; @@ -142,8 +141,7 @@ protected Database getDatabase() { baseConfig.get("port").asText(), baseConfig.get("database").asText()), "com.amazon.redshift.jdbc.Driver", null, - ImmutableMap.of("ssl", "true", "sslfactory", "com.amazon.redshift.ssl.NonValidatingFactory") - ); + "ssl=true;sslfactory=com.amazon.redshift.ssl.NonValidatingFactory"); } @Override