This is an automated email from the ASF dual-hosted git repository.
zykkk pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new b52a02c7de5 [fix](jdbc catalog) Clean up the connection pool after
failure to initialize the client (#31950)
b52a02c7de5 is described below
commit b52a02c7de5b82de269eb12ddf6a59faa3002bea
Author: zy-kkk <[email protected]>
AuthorDate: Wed Mar 13 10:39:16 2024 +0800
[fix](jdbc catalog) Clean up the connection pool after failure to
initialize the client (#31950)
---
.../java/org/apache/doris/datasource/jdbc/client/JdbcClient.java | 4 ++--
.../org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java | 5 +++--
.../apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java | 7 ++++---
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java
index 60daac66b6d..7840e4cf0ae 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcClient.java
@@ -171,8 +171,8 @@ public abstract class JdbcClient {
try {
conn = dataSource.getConnection();
} catch (Exception e) {
- String errorMessage = String.format("Can not connect to jdbc due
to error: %s, Catalog name: %s", e,
- this.getCatalog());
+ String errorMessage = String.format("Can not connect to jdbc due
to error: %s, Catalog name: %s",
+ e.getMessage(), this.getCatalog());
throw new JdbcClientException(errorMessage, e);
}
return conn;
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
index 9e0b4f00dd4..b115559a6b7 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcMySQLClient.java
@@ -56,8 +56,9 @@ public class JdbcMySQLClient extends JdbcClient {
String versionComment = rs.getString("Value");
isDoris = versionComment.toLowerCase().contains("doris");
}
- } catch (SQLException e) {
- throw new JdbcClientException("Failed to determine MySQL Version
Comment", e);
+ } catch (SQLException | JdbcClientException e) {
+ closeClient();
+ throw new JdbcClientException("Failed to initialize
JdbcMySQLClient: %s", e.getMessage());
} finally {
close(rs, stmt, conn);
}
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
index 14d5d5f1848..18cebd7bb96 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/datasource/jdbc/client/JdbcOceanBaseClient.java
@@ -47,11 +47,12 @@ public class JdbcOceanBaseClient extends JdbcClient {
currentClient = new JdbcOracleClient(jdbcClientConfig);
setOracleMode();
} else {
- throw new JdbcClientException("Unsupported compatibility
mode: " + compatibilityMode);
+ throw new JdbcClientException("Unsupported OceanBase
compatibility mode: " + compatibilityMode);
}
}
- } catch (SQLException e) {
- throw new JdbcClientException("Failed to determine OceanBase
compatibility mode", e);
+ } catch (SQLException | JdbcClientException e) {
+ closeClient();
+ throw new JdbcClientException("Failed to initialize
JdbcOceanBaseClient", e.getMessage());
} finally {
close(rs, stmt, conn);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]