[fix](jdbc catalog) Clean up the connection pool after failure to initialize the client (#31949)
This commit is contained in:
@ -169,8 +169,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.getCatalogName());
|
||||
String errorMessage = String.format("Can not connect to jdbc due to error: %s, Catalog name: %s",
|
||||
e.getMessage(), this.getCatalogName());
|
||||
throw new JdbcClientException(errorMessage, e);
|
||||
}
|
||||
return conn;
|
||||
|
||||
@ -54,8 +54,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);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user