Skip to content

Commit

Permalink
[fix](jdbc catalog) Clean up the connection pool after failure to ini…
Browse files Browse the repository at this point in the history
…tialize the client (#31950)
  • Loading branch information
zy-kkk authored Mar 13, 2024
1 parent f2354a6 commit b52a02c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public Connection getConnection() throws JdbcClientException {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ protected JdbcMySQLClient(JdbcClientConfig jdbcClientConfig) {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ public JdbcOceanBaseClient(JdbcClientConfig jdbcClientConfig) {
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);
}
Expand Down

0 comments on commit b52a02c

Please sign in to comment.