You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by ic...@apache.org on 2023/03/21 10:49:13 UTC
[incubator-seatunnel] branch dev updated: [Improve][JdbcSink]Fix connection failure caused by connection timeout. (#4322)
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 e1f6d3b3f [Improve][JdbcSink]Fix connection failure caused by connection timeout. (#4322)
e1f6d3b3f is described below
commit e1f6d3b3fd99a51ccadf20e406766a48f55c0548
Author: lightzhao <40...@users.noreply.github.com>
AuthorDate: Tue Mar 21 18:49:04 2023 +0800
[Improve][JdbcSink]Fix connection failure caused by connection timeout. (#4322)
* Fix connection failure caused by connection timeout.
Co-authored-by: lightzhao <zh...@gmail.com>
---
.../internal/connection/SimpleJdbcConnectionProvider.java | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/connection/SimpleJdbcConnectionProvider.java b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/connection/SimpleJdbcConnectionProvider.java
index 78d2500ea..4358535a2 100644
--- a/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/connection/SimpleJdbcConnectionProvider.java
+++ b/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/connection/SimpleJdbcConnectionProvider.java
@@ -109,7 +109,7 @@ public class SimpleJdbcConnectionProvider implements JdbcConnectionProvider, Ser
@Override
public Connection getOrEstablishConnection() throws SQLException, ClassNotFoundException {
- if (connection != null) {
+ if (isConnectionValid()) {
return connection;
}
Driver driver = getLoadedDriver();
@@ -136,14 +136,14 @@ public class SimpleJdbcConnectionProvider implements JdbcConnectionProvider, Ser
@Override
public void closeConnection() {
- if (connection != null) {
- try {
+ try {
+ if (isConnectionValid()) {
connection.close();
- } catch (SQLException e) {
- LOG.warn("JDBC connection close failed.", e);
- } finally {
- connection = null;
}
+ } catch (SQLException e) {
+ LOG.warn("JDBC connection close failed.", e);
+ } finally {
+ connection = null;
}
}