Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃悶 Snowflake destination: use pooled connections (#10342)
* Use data source conn supplier for snowflake database * Format code * Reuse the same database in integration tests * Close query stream * Refactor snowflake staging sql operations * Close result set * Add annotations * Bump version * Bump version in seed
- Loading branch information
Showing
17 changed files
with
182 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
airbyte-db/lib/src/main/java/io/airbyte/db/jdbc/CloseableConnectionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.db.jdbc; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
|
||
public interface CloseableConnectionSupplier extends AutoCloseable { | ||
|
||
Connection getConnection() throws SQLException; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
airbyte-db/lib/src/main/java/io/airbyte/db/jdbc/DataSourceConnectionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.db.jdbc; | ||
|
||
import java.io.Closeable; | ||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import javax.sql.DataSource; | ||
|
||
public class DataSourceConnectionSupplier implements CloseableConnectionSupplier { | ||
|
||
private final DataSource dataSource; | ||
|
||
public DataSourceConnectionSupplier(final DataSource dataSource) { | ||
this.dataSource = dataSource; | ||
} | ||
|
||
@Override | ||
public Connection getConnection() throws SQLException { | ||
return dataSource.getConnection(); | ||
} | ||
|
||
@Override | ||
public void close() throws Exception { | ||
// Just a safety in case we are using a datasource implementation that requires closing. | ||
// BasicDataSource from apache does since it also provides a pooling mechanism to reuse connections. | ||
|
||
if (dataSource instanceof AutoCloseable) { | ||
((AutoCloseable) dataSource).close(); | ||
} | ||
if (dataSource instanceof Closeable) { | ||
((Closeable) dataSource).close(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.