This is an automated email from the ASF dual-hosted git repository.
ic4y pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 219fea517 Close jdbc connection after use. (#3358)
219fea517 is described below
commit 219fea517c72484df9b9dfde5b63e072cd1a753b
Author: liugddx <[email protected]>
AuthorDate: Fri Nov 11 11:01:55 2022 +0800
Close jdbc connection after use. (#3358)
---
.../connectors/seatunnel/jdbc/source/JdbcSource.java | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git
a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/JdbcSource.java
b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/JdbcSource.java
index 976598099..2fd6f730d 100644
---
a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/JdbcSource.java
+++
b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/source/JdbcSource.java
@@ -77,8 +77,8 @@ public class JdbcSource implements
SeaTunnelSource<SeaTunnelRow, JdbcSourceSplit
jdbcConnectionProvider = new
SimpleJdbcConnectionProvider(jdbcSourceOptions.getJdbcConnectionOptions());
query = jdbcSourceOptions.getJdbcConnectionOptions().query;
jdbcDialect =
JdbcDialectLoader.load(jdbcSourceOptions.getJdbcConnectionOptions().getUrl());
- try {
- typeInfo =
initTableField(jdbcConnectionProvider.getOrEstablishConnection());
+ try (Connection connection =
jdbcConnectionProvider.getOrEstablishConnection()) {
+ typeInfo = initTableField(connection);
partitionParameter =
initPartitionParameterAndExtendSql(jdbcConnectionProvider.getOrEstablishConnection());
} catch (Exception e) {
throw new PrepareFailException("jdbc", PluginType.SOURCE,
e.toString());
@@ -101,16 +101,7 @@ public class JdbcSource implements
SeaTunnelSource<SeaTunnelRow, JdbcSourceSplit
@Override
public SeaTunnelDataType<SeaTunnelRow> getProducedType() {
- Connection conn;
- SeaTunnelRowType seaTunnelDataType = null;
- try {
- conn = jdbcConnectionProvider.getOrEstablishConnection();
- seaTunnelDataType = initTableField(conn);
- } catch (Exception e) {
- LOG.warn("get row type info exception", e);
- }
- this.typeInfo = seaTunnelDataType;
- return seaTunnelDataType;
+ return typeInfo;
}
@Override