[improvement](jdbc catalog) optimize the JDBC Catalog connection error message (#23868)

This commit is contained in:
zy-kkk
2023-09-11 10:26:54 +08:00
committed by GitHub
parent 480fcef0a1
commit d2cd0c30c7
2 changed files with 8 additions and 2 deletions

View File

@ -162,8 +162,9 @@ public abstract class JdbcClient {
try {
conn = dataSource.getConnection();
} catch (Exception e) {
throw new JdbcClientException("Can not connect to jdbc due to error: %s, catalog name: %s", e.getMessage(),
this.catalog, e);
String errorMessage = String.format("Can not connect to jdbc due to error: %s, Catalog name: %s", e,
this.getCatalog());
throw new JdbcClientException(errorMessage, e);
}
return conn;
}

View File

@ -104,6 +104,7 @@ import org.apache.doris.common.util.ProfileManager.ProfileType;
import org.apache.doris.common.util.SqlParserUtils;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.jdbc.client.JdbcClientException;
import org.apache.doris.load.EtlJobType;
import org.apache.doris.load.LoadJobRowResult;
import org.apache.doris.load.loadv2.LoadManager;
@ -778,6 +779,10 @@ public class StmtExecutor {
LOG.warn("execute Exception. {}", context.getQueryIdentifier(), e);
context.getState().setError(e.getMysqlErrorCode(), e.getMessage());
context.getState().setErrType(QueryState.ErrType.ANALYSIS_ERR);
} catch (JdbcClientException e) {
LOG.warn("execute Exception. {}", context.getQueryIdentifier(), e);
context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,
e.getMessage());
} catch (Exception e) {
LOG.warn("execute Exception. {}", context.getQueryIdentifier(), e);
context.getState().setError(ErrorCode.ERR_UNKNOWN_ERROR,