You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/09/20 13:47:58 UTC

[incubator-linkis] branch dev-1.3.1 updated: jdbc module errorcode optimization and documentation (#3473)

This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new 6cb28d657 jdbc module errorcode optimization and documentation (#3473)
6cb28d657 is described below

commit 6cb28d657f329476557b953273aa1fe98c52dd63
Author: huangxiaoping <35...@users.noreply.github.com>
AuthorDate: Tue Sep 20 21:47:51 2022 +0800

    jdbc module errorcode optimization and documentation (#3473)
---
 docs/errorcode/linkis-engineplugin-jdbc.md         |  27 ++++
 .../engineplugin/jdbc/ConnectionManager.java       |  23 ++-
 .../jdbc/errorcode/JDBCErrorCodeSummary.java       | 177 +++++++++++++++++++++
 .../engineplugin/jdbc/utils/JdbcParamUtils.java    |   8 +-
 .../jdbc/exception/JDBCDatasourceException.scala   |   7 +-
 .../exception/JDBCParamsIllegalException.scala     |   9 +-
 .../jdbc/executor/JDBCEngineConnExecutor.scala     |   4 +-
 .../jdbc/executor/JDBCMultiDatasourceParser.scala  |  54 +++++--
 .../jdbc/errorcode/JDBCErrorCodeSummaryTest.java   | 119 ++++++++++++++
 9 files changed, 398 insertions(+), 30 deletions(-)

diff --git a/docs/errorcode/linkis-engineplugin-jdbc.md b/docs/errorcode/linkis-engineplugin-jdbc.md
new file mode 100644
index 000000000..23c67e08a
--- /dev/null
+++ b/docs/errorcode/linkis-engineplugin-jdbc.md
@@ -0,0 +1,27 @@
+## linkis-engineplugin-jdbc errorcode
+
+
+| 模块名(服务名) | 错误码   | 描述 | module |
+| -------- |-------| ----- |----|
+|linkis-engineplugin-jdbc| 26010 |Failed to get datasource info from datasource server(从数据源服务器获取数据源信息失败)|jdbcEngineConnExecutor|
+|linkis-engineplugin-jdbc| 26011 |JDBC related parameters are illegal(JDBC相关参数非法)|jdbc|
+|linkis-engineplugin-jdbc| 26012 |The driver class name is required(驱动程序类名是必需的)|connectionManager|
+|linkis-engineplugin-jdbc| 26013 |Unsupported jdbc authentication types(不支持的 jdbc 身份验证类型)|connectionManager|
+|linkis-engineplugin-jdbc| 26014 |No execUser(没有执行用户参数)|connectionManager|
+|linkis-engineplugin-jdbc| 26015 |Error in getCurrentUser(获取当前用户出错)|connectionManager|
+|linkis-engineplugin-jdbc| 26016 |Error in doAs to get one connection(doAs 获取一个连接时出错)|connectionManager|
+|linkis-engineplugin-jdbc| 26017 |The jdbc username is not empty(jdbc用户名不为空)|jdbcParamUtils|
+|linkis-engineplugin-jdbc| 26018 |The jdbc password is not empty(jdbc密码不为空)|jdbcParamUtils|
+|linkis-engineplugin-jdbc| 26019 |Data source info not found(数据源信息未找到)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26020 |Data source not yet published(数据源尚未发布)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26021 |Data source is expired(数据源已过期)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26022 |The data source jdbc type cannot be null(数据源 jdbc 类型不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26023 |The data source jdbc connection info cannot be null(数据源 jdbc 连接信息不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26024 |The data source jdbc driverClassName cannot be null(数据源 jdbc driverClassName 不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26025 |The data source jdbc connection host cannot be null(数据源jdbc连接主机不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26026 |The data source jdbc connection port cannot be null(数据源jdbc连接端口不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26027 |In the jdbc authentication mode of kerberos, the kerberos principal cannot be empty(kerberos的jdbc认证方式下,kerberos principal不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26028 |In the jdbc authentication mode of kerberos, the kerberos keytab cannot be empty(kerberos的jdbc认证方式下,kerberos keytab不能为空)|jdbcMultiDatasourceParser|
+|linkis-engineplugin-jdbc| 26029 |Unsupported authentication type(不支持的身份验证类型)|jdbcMultiDatasourceParser|
+
+
diff --git a/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java
index d8fa17478..071399fe4 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java
+++ b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/ConnectionManager.java
@@ -41,6 +41,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import static org.apache.linkis.manager.engineplugin.jdbc.JdbcAuthType.*;
+import static org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary.*;
 
 public class ConnectionManager {
   private static final Logger LOG = LoggerFactory.getLogger(ConnectionManager.class);
@@ -114,7 +115,8 @@ public class ConnectionManager {
         JDBCPropertiesParser.getString(properties, JDBCEngineConnConstant.JDBC_DRIVER, "");
     if (StringUtils.isBlank(driverClassName)) {
       LOG.error("The driver class name is required.");
-      throw new JDBCParamsIllegalException("The driver class name is required.");
+      throw new JDBCParamsIllegalException(
+          DRIVER_CLASS_NAME_ERROR.getErrorCode(), DRIVER_CLASS_NAME_ERROR.getErrorDesc());
     }
 
     String username = JdbcParamUtils.getJdbcUsername(properties);
@@ -132,7 +134,11 @@ public class ConnectionManager {
         break;
       default:
         throw new JDBCParamsIllegalException(
-            "Unsupported jdbc authentication types " + jdbcAuthType.getAuthType());
+            UNSUPPORT_JDBC_AUTHENTICATION_TYPES.getErrorCode(),
+            UNSUPPORT_JDBC_AUTHENTICATION_TYPES
+                .getErrorDesc()
+                .concat("  ")
+                .concat(jdbcAuthType.getAuthType()));
     }
 
     boolean testOnBorrow =
@@ -219,7 +225,8 @@ public class ConnectionManager {
             properties, JDBCEngineConnConstant.JDBC_SCRIPTS_EXEC_USER, "");
     if (StringUtils.isBlank(execUser)) {
       LOG.warn("No such execUser: {}", execUser);
-      throw new JDBCParamsIllegalException("No execUser");
+      throw new JDBCParamsIllegalException(
+          NO_EXEC_USER_ERROR.getErrorCode(), NO_EXEC_USER_ERROR.getErrorDesc());
     }
     Connection connection = null;
     final String jdbcUrl = getJdbcUrl(properties);
@@ -261,7 +268,8 @@ public class ConnectionManager {
                     execUser, UserGroupInformation.getCurrentUser());
           } catch (Exception e) {
             LOG.error("Error in getCurrentUser", e);
-            throw new JDBCParamsIllegalException("Error in getCurrentUser");
+            throw new JDBCParamsIllegalException(
+                GET_CURRENT_USER_ERROR.getErrorCode(), GET_CURRENT_USER_ERROR.getErrorDesc());
           }
 
           try {
@@ -271,13 +279,16 @@ public class ConnectionManager {
                         () ->
                             getConnectionFromDataSource(dataSourceIdentifier, jdbcUrl, properties));
           } catch (Exception e) {
-            throw new JDBCParamsIllegalException("Error in doAs to get one connection.");
+            throw new JDBCParamsIllegalException(
+                DOAS_FOR_GET_CONNECTION_ERROR.getErrorCode(),
+                DOAS_FOR_GET_CONNECTION_ERROR.getErrorDesc());
           }
         }
         break;
       default:
         throw new JDBCParamsIllegalException(
-            "Unsupported jdbc authentication types " + jdbcAuthType.getAuthType());
+            UNSUPPORT_JDBC_AUTHENTICATION_TYPES.getErrorCode(),
+            UNSUPPORT_JDBC_AUTHENTICATION_TYPES.getErrorDesc() + jdbcAuthType.getAuthType());
     }
     return connection;
   }
diff --git a/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummary.java b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummary.java
new file mode 100644
index 000000000..b816faaa3
--- /dev/null
+++ b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummary.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.manager.engineplugin.jdbc.errorcode;
+
+import org.apache.linkis.common.errorcode.ErrorCodeUtils;
+
+public enum JDBCErrorCodeSummary {
+  /**
+   * 10000-10999 linkis-frame 11000-12999 linkis-commons 13000-14999 linkis-spring-cloud-services
+   * 15000-19999 linkis-public-enhancements 20000-24999 linkis-computation-governance 25000-25999
+   * linkis-extensions 26000-29999 linkis-engineconn-plugins
+   */
+  JDBC_GET_DATASOURCEINFO_ERROR(
+      26010,
+      "Failed to get datasource info from datasource server(从数据源服务器获取数据源信息失败)",
+      "Unable to get datasource information from datasource server due to some error(由于某些错误,无法从数据源服务器获取数据源信息)",
+      "jdbcEngineConnExecutor"),
+  JDBC_PARAMS_ILLEGAL(
+      26011,
+      "JDBC related parameters are illegal(JDBC相关参数非法)",
+      "JDBC related parameters do not meet the requirements, may be empty or not set, etc(jdbc相关参数不符合要求,可能为空或者没有设置等)",
+      "jdbc"),
+  DRIVER_CLASS_NAME_ERROR(
+      26012,
+      "The driver class name is required(驱动程序类名是必需的)",
+      "Driver class name must be set(必须设置驱动程序类名)",
+      "connectionManager"),
+  UNSUPPORT_JDBC_AUTHENTICATION_TYPES(
+      26013,
+      "Unsupported jdbc authentication types(不支持的 jdbc 身份验证类型)",
+      "Some jdbc types of authentication are not supported(某些jdbc类型的身份认证不支持)",
+      "connectionManager"),
+  NO_EXEC_USER_ERROR(26014, "No execUser(没有执行用户参数)", "No execUser(没有执行用户参数)", "connectionManager"),
+  GET_CURRENT_USER_ERROR(
+      26015,
+      "Error in getCurrentUser(获取当前用户出错)",
+      "Error getting current user in some cases(某些情况下获取当前用户出错)",
+      "connectionManager"),
+  DOAS_FOR_GET_CONNECTION_ERROR(
+      26016,
+      "Error in doAs to get one connection(doAs 获取一个连接时出错)",
+      "Error getting a connection via doAs(通过doAs 的方式获取一个连接时出错)",
+      "connectionManager"),
+  JDBC_USERNAME_NOT_EMPTY(
+      26017,
+      "The jdbc username is not empty(jdbc用户名不为空)",
+      "The username of jdbc must be set(必须设置 jdbc的username)",
+      "jdbcParamUtils"),
+  JDBC_PASSWORD_NOT_EMPTY(
+      26018,
+      "The jdbc password is not empty(jdbc密码不为空)",
+      "The password of jdbc must be set(必须设置 jdbc的password)",
+      "jdbcParamUtils"),
+  DATA_SOURCE_INFO_NOT_FOUND(
+      26019,
+      "Data source info not found(数据源信息未找到)",
+      "Data source info not found(数据源信息未找到)",
+      "jdbcMultiDatasourceParser"),
+  DATA_SOURCE_NOT_PUBLISHED(
+      26020,
+      "Data source not yet published(数据源尚未发布)",
+      "Data source not yet published(数据源尚未发布)",
+      "jdbcMultiDatasourceParser"),
+  DATA_SOURCE_EXPIRED(
+      26021,
+      "Data source is expired(数据源已过期)",
+      "Data source is expired(数据源已过期)",
+      "jdbcMultiDatasourceParser"),
+  DATA_SOURCE_JDBC_TYPE_NOT_NULL(
+      26022,
+      "The data source jdbc type cannot be null(数据源 jdbc 类型不能为空)",
+      "The data source jdbc type cannot be null(数据源 jdbc 类型不能为空)",
+      "jdbcMultiDatasourceParser"),
+  JDBC_CONNECTION_INFO_NOT_NULL(
+      26023,
+      "The data source jdbc connection info cannot be null(数据源 jdbc 连接信息不能为空)",
+      "The data source jdbc connection info cannot be null(数据源 jdbc 连接信息不能为空)",
+      "jdbcMultiDatasourceParser"),
+  JDBC_DRIVER_CLASS_NAME_NOT_NULL(
+      26024,
+      "The data source jdbc driverClassName cannot be null(数据源 jdbc driverClassName 不能为空)",
+      "The data source jdbc driverClassName cannot be null(数据源 jdbc driverClassName 不能为空)",
+      "jdbcMultiDatasourceParser"),
+  JDBC_HOST_NOT_NULL(
+      26025,
+      "The data source jdbc connection host cannot be null(数据源jdbc连接主机不能为空)",
+      "The data source jdbc connection host cannot be null(数据源jdbc连接主机不能为空)",
+      "jdbcMultiDatasourceParser"),
+  JDBC_PORT_NOT_NULL(
+      26026,
+      "The data source jdbc connection port cannot be null(数据源jdbc连接端口不能为空)",
+      "The data source jdbc connection port cannot be null(数据源jdbc连接端口不能为空)",
+      "jdbcMultiDatasourceParser"),
+  KERBEROS_PRINCIPAL_NOT_NULL(
+      26027,
+      "In the jdbc authentication mode of kerberos, the kerberos principal cannot be empty(kerberos的jdbc认证方式下,kerberos principal不能为空)",
+      "In the jdbc authentication mode of kerberos, the kerberos principal cannot be empty(kerberos的jdbc认证方式下,kerberos principal不能为空)",
+      "jdbcMultiDatasourceParser"),
+  KERBEROS_KEYTAB_NOT_NULL(
+      26028,
+      "In the jdbc authentication mode of kerberos, the kerberos keytab cannot be empty(kerberos的jdbc认证方式下,kerberos keytab不能为空)",
+      "In the jdbc authentication mode of kerberos, the kerberos keytab cannot be empty(kerberos的jdbc认证方式下,kerberos keytab不能为空)",
+      "jdbcMultiDatasourceParser"),
+  UNSUPPORTED_AUTHENTICATION_TYPE(
+      26029,
+      "Unsupported authentication type(不支持的身份验证类型)",
+      "Some authentication types are not supported(Some authentication types are not supported)",
+      "jdbcMultiDatasourceParser");
+
+  private int errorCode;
+
+  private String errorDesc;
+
+  private String comment;
+
+  private String module;
+
+  JDBCErrorCodeSummary(int errorCode, String errorDesc, String comment, String module) {
+    ErrorCodeUtils.validateErrorCode(errorCode, 26000, 29999);
+    this.errorCode = errorCode;
+    this.errorDesc = errorDesc;
+    this.comment = comment;
+    this.module = module;
+  }
+
+  public int getErrorCode() {
+    return errorCode;
+  }
+
+  public void setErrorCode(int errorCode) {
+    this.errorCode = errorCode;
+  }
+
+  public String getErrorDesc() {
+    return errorDesc;
+  }
+
+  public void setErrorDesc(String errorDesc) {
+    this.errorDesc = errorDesc;
+  }
+
+  public String getComment() {
+    return comment;
+  }
+
+  public void setComment(String comment) {
+    this.comment = comment;
+  }
+
+  public String getModule() {
+    return module;
+  }
+
+  public void setModule(String module) {
+    this.module = module;
+  }
+
+  @Override
+  public String toString() {
+    return "errorCode: " + this.errorCode + ", errorDesc:" + this.errorDesc;
+  }
+}
diff --git a/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/utils/JdbcParamUtils.java b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/utils/JdbcParamUtils.java
index a6d3c7961..24171de4d 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/utils/JdbcParamUtils.java
+++ b/linkis-engineconn-plugins/jdbc/src/main/java/org/apache/linkis/manager/engineplugin/jdbc/utils/JdbcParamUtils.java
@@ -28,6 +28,8 @@ import java.util.Map;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary.*;
+
 public class JdbcParamUtils {
   private static final Logger LOG = LoggerFactory.getLogger(JdbcParamUtils.class);
   private static final String JDBC_MATCH_REGEX = "jdbc:\\w+://\\S+:[0-9]{2,6}(/\\S*)?";
@@ -93,7 +95,8 @@ public class JdbcParamUtils {
     String username =
         JDBCPropertiesParser.getString(properties, JDBCEngineConnConstant.JDBC_USERNAME, "");
     if (StringUtils.isBlank(username)) {
-      throw new JDBCParamsIllegalException("The jdbc username is not empty.");
+      throw new JDBCParamsIllegalException(
+          JDBC_USERNAME_NOT_EMPTY.getErrorCode(), JDBC_USERNAME_NOT_EMPTY.getErrorDesc());
     }
     if (username.contains(AUTO_DESERIALIZE)) {
       LOG.warn("Sensitive param : {} in username field is filtered.", AUTO_DESERIALIZE);
@@ -108,7 +111,8 @@ public class JdbcParamUtils {
     String password =
         JDBCPropertiesParser.getString(properties, JDBCEngineConnConstant.JDBC_PASSWORD, "");
     if (StringUtils.isBlank(password)) {
-      throw new JDBCParamsIllegalException("The jdbc password is not empty.");
+      throw new JDBCParamsIllegalException(
+          JDBC_PASSWORD_NOT_EMPTY.getErrorCode(), JDBC_PASSWORD_NOT_EMPTY.getErrorDesc());
     }
     if (password.contains(AUTO_DESERIALIZE)) {
       LOG.warn("Sensitive param : {} in password field is filtered", AUTO_DESERIALIZE);
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala
index d9d14653d..200bb6987 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala
@@ -19,10 +19,11 @@ package org.apache.linkis.manager.engineplugin.jdbc.exception
 
 import org.apache.linkis.common.exception.ErrorException
 
-class JDBCGetDatasourceInfoException(errorDesc: String) extends ErrorException(70022, errorDesc) {
+class JDBCGetDatasourceInfoException(errorCode: Int, errorDesc: String)
+    extends ErrorException(errorCode, errorDesc) {
 
-  def this(errorDesc: String, t: Throwable) = {
-    this(errorDesc)
+  def this(errorCode: Int, errorDesc: String, t: Throwable) = {
+    this(errorCode, errorDesc)
     super.initCause(t)
   }
 
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCParamsIllegalException.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCParamsIllegalException.scala
index b4298b3be..8e3680ef6 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCParamsIllegalException.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCParamsIllegalException.scala
@@ -19,10 +19,5 @@ package org.apache.linkis.manager.engineplugin.jdbc.exception
 
 import org.apache.linkis.common.exception.ErrorException
 
-case class JDBCParamsIllegalException(errorMsg: String) extends ErrorException(70012, errorMsg)
-
-case class JDBCSQLFeatureNotSupportedException(errorMsg: String)
-    extends ErrorException(70013, errorMsg)
-
-case class JDBCStateMentNotInitialException(errorMsg: String)
-    extends ErrorException(70014, errorMsg)
+case class JDBCParamsIllegalException(errorCode: Int, errorMsg: String)
+    extends ErrorException(errorCode, errorMsg)
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
index 5423d6155..ce582be7d 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCEngineConnExecutor.scala
@@ -38,6 +38,7 @@ import org.apache.linkis.manager.engineplugin.common.conf.EngineConnPluginConf
 import org.apache.linkis.manager.engineplugin.jdbc.ConnectionManager
 import org.apache.linkis.manager.engineplugin.jdbc.conf.JDBCConfiguration
 import org.apache.linkis.manager.engineplugin.jdbc.constant.JDBCEngineConnConstant
+import org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary.JDBC_GET_DATASOURCEINFO_ERROR
 import org.apache.linkis.manager.engineplugin.jdbc.exception.JDBCGetDatasourceInfoException
 import org.apache.linkis.manager.engineplugin.jdbc.monitor.ProgressMonitor
 import org.apache.linkis.manager.label.entity.Label
@@ -221,7 +222,8 @@ class JDBCEngineConnExecutor(override val outputPrintLimit: Int, val id: Int)
         )
       } { e: Throwable =>
         throw new JDBCGetDatasourceInfoException(
-          s"Failed to get datasource info about [$dataSourceName] from datasource server.",
+          JDBC_GET_DATASOURCEINFO_ERROR.getErrorCode,
+          JDBC_GET_DATASOURCEINFO_ERROR.getErrorDesc.concat(" ").concat(s"[$dataSourceName]"),
           e
         )
       }
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCMultiDatasourceParser.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCMultiDatasourceParser.scala
index 16b139643..a96d6b192 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCMultiDatasourceParser.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executor/JDBCMultiDatasourceParser.scala
@@ -23,6 +23,7 @@ import org.apache.linkis.datasource.client.request.GetInfoPublishedByDataSourceN
 import org.apache.linkis.datasourcemanager.common.domain.DataSource
 import org.apache.linkis.manager.engineplugin.jdbc.JdbcAuthType
 import org.apache.linkis.manager.engineplugin.jdbc.constant.JDBCEngineConnConstant
+import org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary._
 import org.apache.linkis.manager.engineplugin.jdbc.exception.JDBCParamsIllegalException
 
 import org.apache.commons.lang3.StringUtils
@@ -63,11 +64,17 @@ object JDBCMultiDatasourceParser extends Logging {
     val dsConnInfo = new util.HashMap[String, String]()
 
     if (strObjIsBlank(dataSource)) {
-      throw JDBCParamsIllegalException(s"Data source [$datasourceName] info not found!")
+      throw JDBCParamsIllegalException(
+        DATA_SOURCE_INFO_NOT_FOUND.getErrorCode,
+        DATA_SOURCE_INFO_NOT_FOUND.getErrorDesc.concat(" ").concat(s"[$datasourceName]")
+      )
     }
 
     if (dataSource.getPublishedVersionId == null || dataSource.getPublishedVersionId <= 0) {
-      throw JDBCParamsIllegalException(s"Data source [$datasourceName] not yet published!")
+      throw JDBCParamsIllegalException(
+        DATA_SOURCE_NOT_PUBLISHED.getErrorCode,
+        DATA_SOURCE_NOT_PUBLISHED.getErrorDesc.concat(" ").concat(s"[$datasourceName]")
+      )
     }
 
     var maxVersionId = "0"
@@ -77,7 +84,10 @@ object JDBCMultiDatasourceParser extends Logging {
     dsConnInfo.put(JDBCEngineConnConstant.JDBC_ENGINE_RUN_TIME_DS_MAX_VERSION_ID, maxVersionId)
 
     if (dataSource.isExpire) {
-      throw JDBCParamsIllegalException(s"Data source [$datasourceName] is expired!")
+      throw JDBCParamsIllegalException(
+        DATA_SOURCE_EXPIRED.getErrorCode,
+        DATA_SOURCE_EXPIRED.getErrorDesc.concat(" ").concat(s"[$datasourceName]")
+      )
     }
 
     if (
@@ -85,18 +95,27 @@ object JDBCMultiDatasourceParser extends Logging {
           dataSource.getDataSourceType.getName
         )
     ) {
-      throw JDBCParamsIllegalException("The data source jdbc type cannot be null!")
+      throw JDBCParamsIllegalException(
+        DATA_SOURCE_JDBC_TYPE_NOT_NULL.getErrorCode,
+        DATA_SOURCE_JDBC_TYPE_NOT_NULL.getErrorDesc
+      )
     }
 
     val dbType = dataSource.getDataSourceType.getName
     val dbConnParams = dataSource.getConnectParams
     if (dbConnParams == null || dbConnParams.isEmpty) {
-      throw JDBCParamsIllegalException("The data source jdbc connection info cannot be null!")
+      throw JDBCParamsIllegalException(
+        JDBC_CONNECTION_INFO_NOT_NULL.getErrorCode,
+        JDBC_CONNECTION_INFO_NOT_NULL.getErrorDesc
+      )
     }
 
     val driverClassName = dbConnParams.get(JDBCEngineConnConstant.DS_JDBC_DRIVER)
     if (strObjIsBlank(driverClassName)) {
-      throw JDBCParamsIllegalException("The data source jdbc driverClassName cannot be null!")
+      throw JDBCParamsIllegalException(
+        JDBC_DRIVER_CLASS_NAME_NOT_NULL.getErrorCode,
+        JDBC_DRIVER_CLASS_NAME_NOT_NULL.getErrorDesc
+      )
     }
 
     val jdbcUrl = createJdbcUrl(dbType, dbConnParams)
@@ -109,11 +128,17 @@ object JDBCMultiDatasourceParser extends Logging {
   def createJdbcUrl(dbType: String, dbConnParams: util.Map[String, Object]): String = {
     val host = dbConnParams.get(JDBCEngineConnConstant.DS_JDBC_HOST)
     if (strObjIsBlank(host)) {
-      throw JDBCParamsIllegalException("The data source jdbc connection host cannot be null!")
+      throw JDBCParamsIllegalException(
+        JDBC_HOST_NOT_NULL.getErrorCode,
+        JDBC_HOST_NOT_NULL.getErrorDesc
+      )
     }
     val port = dbConnParams.get(JDBCEngineConnConstant.DS_JDBC_PORT)
     if (strObjIsBlank(port)) {
-      throw JDBCParamsIllegalException("The data source jdbc connection port cannot be null!")
+      throw JDBCParamsIllegalException(
+        JDBC_PORT_NOT_NULL.getErrorCode,
+        JDBC_PORT_NOT_NULL.getErrorDesc
+      )
     }
     var jdbcUrl = s"jdbc:$dbType://$host:$port"
     val dbName = dbConnParams.get(JDBCEngineConnConstant.DS_JDBC_DB_NAME)
@@ -158,12 +183,14 @@ object JDBCMultiDatasourceParser extends Logging {
         authType = JdbcAuthType.KERBEROS
         if (strObjIsBlank(kerberosPrincipal)) {
           throw JDBCParamsIllegalException(
-            "In the jdbc authentication mode of kerberos, the kerberos principal cannot be empty!"
+            KERBEROS_PRINCIPAL_NOT_NULL.getErrorCode,
+            KERBEROS_PRINCIPAL_NOT_NULL.getErrorDesc
           )
         }
         if (strObjIsBlank(kerberosKeytab)) {
           throw JDBCParamsIllegalException(
-            "In the jdbc authentication mode of kerberos, the kerberos keytab cannot be empty!"
+            KERBEROS_KEYTAB_NOT_NULL.getErrorCode,
+            KERBEROS_KEYTAB_NOT_NULL.getErrorDesc
           )
         }
       } else {
@@ -203,7 +230,12 @@ object JDBCMultiDatasourceParser extends Logging {
           )
         }
       case _ =>
-        throw JDBCParamsIllegalException(s"Unsupported authentication type ${authType.getAuthType}")
+        throw JDBCParamsIllegalException(
+          UNSUPPORTED_AUTHENTICATION_TYPE.getErrorCode,
+          UNSUPPORTED_AUTHENTICATION_TYPE.getErrorDesc
+            .concat(" ")
+            .concat(s"${authType.getAuthType}")
+        )
     }
     dsConnInfo.put(JDBCEngineConnConstant.JDBC_AUTH_TYPE, authType.getAuthType)
     dsConnInfo
diff --git a/linkis-engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummaryTest.java b/linkis-engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummaryTest.java
new file mode 100644
index 000000000..7e3ac7d76
--- /dev/null
+++ b/linkis-engineconn-plugins/jdbc/src/test/java/org/apache/linkis/manager/engineplugin/jdbc/errorcode/JDBCErrorCodeSummaryTest.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.manager.engineplugin.jdbc.errorcode;
+
+import org.junit.jupiter.api.Test;
+
+import static org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary.JDBC_GET_DATASOURCEINFO_ERROR;
+import static org.apache.linkis.manager.engineplugin.jdbc.errorcode.JDBCErrorCodeSummary.JDBC_PARAMS_ILLEGAL;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class JDBCErrorCodeSummaryTest {
+  @Test
+  void testGetErrorCode() {
+    assertEquals(26010, JDBC_GET_DATASOURCEINFO_ERROR.getErrorCode());
+    assertEquals(26011, JDBC_PARAMS_ILLEGAL.getErrorCode());
+  }
+
+  @Test
+  void testSetErrorCode() {
+    JDBC_GET_DATASOURCEINFO_ERROR.setErrorCode(1);
+    assertEquals(1, JDBC_GET_DATASOURCEINFO_ERROR.getErrorCode());
+    JDBC_GET_DATASOURCEINFO_ERROR.setErrorCode(26010);
+    assertEquals(26010, JDBC_GET_DATASOURCEINFO_ERROR.getErrorCode());
+
+    JDBC_PARAMS_ILLEGAL.setErrorCode(1);
+    assertEquals(1, JDBC_PARAMS_ILLEGAL.getErrorCode());
+    JDBC_PARAMS_ILLEGAL.setErrorCode(26011);
+    assertEquals(26011, JDBC_PARAMS_ILLEGAL.getErrorCode());
+  }
+
+  @Test
+  void testGetErrorDesc() {
+    assertEquals(
+        "Failed to get datasource info from datasource server(从数据源服务器获取数据源信息失败)",
+        JDBC_GET_DATASOURCEINFO_ERROR.getErrorDesc());
+    assertEquals(
+        "JDBC related parameters are illegal(JDBC相关参数非法)", JDBC_PARAMS_ILLEGAL.getErrorDesc());
+  }
+
+  @Test
+  void testSetErrorDesc() {
+    JDBC_GET_DATASOURCEINFO_ERROR.setErrorDesc("test");
+    assertEquals("test", JDBC_GET_DATASOURCEINFO_ERROR.getErrorDesc());
+    JDBC_GET_DATASOURCEINFO_ERROR.setErrorDesc(
+        "Failed to get datasource info from datasource server(从数据源服务器获取数据源信息失败)");
+    assertEquals(
+        "Failed to get datasource info from datasource server(从数据源服务器获取数据源信息失败)",
+        JDBC_GET_DATASOURCEINFO_ERROR.getErrorDesc());
+
+    JDBC_PARAMS_ILLEGAL.setErrorDesc("test");
+    assertEquals("test", JDBC_PARAMS_ILLEGAL.getErrorDesc());
+    JDBC_PARAMS_ILLEGAL.setErrorDesc("JDBC related parameters are illegal(JDBC相关参数非法)");
+    assertEquals(
+        "JDBC related parameters are illegal(JDBC相关参数非法)", JDBC_PARAMS_ILLEGAL.getErrorDesc());
+  }
+
+  @Test
+  void testGetComment() {
+    assertEquals(
+        "Unable to get datasource information from datasource server due to some error(由于某些错误,无法从数据源服务器获取数据源信息)",
+        JDBC_GET_DATASOURCEINFO_ERROR.getComment());
+    assertEquals(
+        "JDBC related parameters do not meet the requirements, may be empty or not set, etc(jdbc相关参数不符合要求,可能为空或者没有设置等)",
+        JDBC_PARAMS_ILLEGAL.getComment());
+  }
+
+  @Test
+  void testSetComment() {
+    JDBC_GET_DATASOURCEINFO_ERROR.setComment("test");
+    assertEquals("test", JDBC_GET_DATASOURCEINFO_ERROR.getComment());
+    JDBC_GET_DATASOURCEINFO_ERROR.setComment(
+        "Unable to get datasource information from datasource server due to some error(由于某些错误,无法从数据源服务器获取数据源信息)");
+    assertEquals(
+        "Unable to get datasource information from datasource server due to some error(由于某些错误,无法从数据源服务器获取数据源信息)",
+        JDBC_GET_DATASOURCEINFO_ERROR.getComment());
+
+    JDBC_PARAMS_ILLEGAL.setComment("test");
+    assertEquals("test", JDBC_PARAMS_ILLEGAL.getComment());
+    JDBC_PARAMS_ILLEGAL.setComment(
+        "JDBC related parameters do not meet the requirements, may be empty or not set, etc(jdbc相关参数不符合要求,可能为空或者没有设置等)");
+    assertEquals(
+        "JDBC related parameters do not meet the requirements, may be empty or not set, etc(jdbc相关参数不符合要求,可能为空或者没有设置等)",
+        JDBC_PARAMS_ILLEGAL.getComment());
+  }
+
+  @Test
+  void testGetModule() {
+    assertEquals("jdbc", JDBC_GET_DATASOURCEINFO_ERROR.getModule());
+    assertEquals("jdbc", JDBC_PARAMS_ILLEGAL.getModule());
+  }
+
+  @Test
+  void testSetModule() {
+    JDBC_GET_DATASOURCEINFO_ERROR.setModule("test");
+    assertEquals("test", JDBC_GET_DATASOURCEINFO_ERROR.getModule());
+    JDBC_GET_DATASOURCEINFO_ERROR.setModule("jdbc");
+    assertEquals("jdbc", JDBC_GET_DATASOURCEINFO_ERROR.getModule());
+
+    JDBC_PARAMS_ILLEGAL.setModule("test");
+    assertEquals("test", JDBC_PARAMS_ILLEGAL.getModule());
+    JDBC_PARAMS_ILLEGAL.setModule("jdbc");
+    assertEquals("jdbc", JDBC_PARAMS_ILLEGAL.getModule());
+  }
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org