You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2022/09/11 15:36:27 UTC

[shardingsphere] branch master updated: Adjust KernelSQLException's vendor codes (#20930)

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

zhaojinchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new f7e511be1b9 Adjust KernelSQLException's vendor codes (#20930)
f7e511be1b9 is described below

commit f7e511be1b976124e327a3a0f93315552b08d895
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Sun Sep 11 23:36:19 2022 +0800

    Adjust KernelSQLException's vendor codes (#20930)
    
    * Adjust KernelSQLException's vendor codes
    
    * Adjust KernelSQLException's vendor codes
    
    * Adjust KernelSQLException's vendor codes
---
 .../user-manual/error-code/sql-error-code.cn.md    | 68 +++++++++++-----------
 .../user-manual/error-code/sql-error-code.en.md    | 44 +++++++-------
 .../exception/InvalidDataNodesFormatException.java |  2 +-
 .../OverallConnectionNotEnoughException.java       |  2 +-
 .../exception/DatetimeLoadingException.java        |  2 +-
 .../UnsupportedDataTypeConversionException.java    |  2 +-
 ...nsupportedStreamCharsetConversionException.java |  2 +-
 .../sql/type/kernel/KernelSQLException.java        |  2 +-
 .../sql/type/kernel/KernelSQLExceptionTest.java    | 14 +----
 .../driver/DriverRegisterException.java            |  2 +-
 .../connection/ConnectionClosedException.java      |  2 +-
 .../connection/ResultSetClosedException.java       |  2 +-
 .../syntax/ColumnIndexOutOfRangeException.java     |  2 +-
 .../syntax/ColumnLabelNotFoundException.java       |  2 +-
 .../JDBCTransactionAcrossDatabasesException.java   |  2 +-
 .../exception/DropNotEmptySchemaException.java     |  2 +-
 .../exception/SchemaNotFoundException.java         |  2 +-
 .../exception/SingleTableNotFoundException.java    |  2 +-
 .../UnsupportedDropCascadeTableException.java      |  2 +-
 .../OptimizationSQLNodeConvertException.java       |  2 +-
 .../exception/XADataSourceInitializeException.java |  2 +-
 .../XATransactionNestedBeginException.java         |  2 +-
 .../backend/exception/InvalidValueException.java   |  2 +-
 .../exception/ResourceNotExistedException.java     |  2 +-
 .../backend/exception/RuleNotExistedException.java |  2 +-
 .../frontend/exception/CircuitBreakException.java  |  2 +-
 .../mysql/err/MySQLErrPacketFactoryTest.java       |  2 +-
 27 files changed, 82 insertions(+), 92 deletions(-)

diff --git a/docs/document/content/user-manual/error-code/sql-error-code.cn.md b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
index 41962c2b930..ce035a98c1c 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.cn.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.cn.md
@@ -14,83 +14,83 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
+| 42000     | 10000       | Resource does not exist |
 | 08000     | 10001       | The URL \`%s\` is not recognized, please refer to the pattern \`%s\` |
 | 42000     | 10002       | Can not support 3-tier structure for actual data node \`%s\` with JDBC \`%s\` |
-| 42000     | 10003       | Unsupported SQL node conversion for SQL statement \`%s\` |
-| 42000     | 10012       | Resource does not exist |
-| 42000     | 10013       | Rule does not exist |
-| HY004     | 10014       | Invalid format for actual data node \`%s\` |
-| 42S02     | 10020       | Single table \`%s\` does not exist |
-| 42S02     | 10021       | Schema \`%s\` does not exist |
+| HY004     | 10003       | Invalid format for actual data node \`%s\` |
+| 42000     | 10004       | Unsupported SQL node conversion for SQL statement \`%s\` |
+| 42000     | 10010       | Rule does not exist |
+| 42S02     | 10020       | Schema \`%s\` does not exist |
+| 42S02     | 10021       | Single table \`%s\` does not exist |
 | HY000     | 10022       | Can not load table with database name \`%s\` and data source name \`%s\` |
-| 0A000     | 10023       | Can not drop schema \`%s\` because of contains tables |
+| 0A000     | 11030       | Can not drop schema \`%s\` because of contains tables |
 
 ### 数据
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| HY004     | 10101       | Invalid value \`%s\` |
-| HY004     | 10105       | Unsupported conversion stream charset \`%s\` |
-| HY004     | 10106       | Unsupported conversion data type \`%s\` for value \`%s\` |
+| HY004     | 11000       | Invalid value \`%s\` |
+| HY004     | 11001       | Unsupported conversion data type \`%s\` for value \`%s\` |
+| HY004     | 11010       | Unsupported conversion stream charset \`%s\` |
 
 ### 语法
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| 42000     | 10200       | You have an error in your SQL syntax: %s |
-| 42000     | 10201       | SQL String can not be NULL or empty |
-| 42000     | 10202       | Could not support variable \`%s\` |
-| 0A000     | 10203       | DROP TABLE ... CASCADE is not supported |
-| 42S02     | 10204       | Can not find column label \`%s\` |
-| HV008     | 10205       | Column index \`%d\` is out of range |
+| 42000     | 12000       | You have an error in your SQL syntax: %s |
+| 42000     | 12001       | SQL String can not be NULL or empty |
+| 42000     | 12002       | Could not support variable \`%s\` |
+| 42S02     | 12003       | Can not find column label \`%s\` |
+| HV008     | 12004       | Column index \`%d\` is out of range |
+| 0A000     | 12010       | DROP TABLE ... CASCADE is not supported |
 
 ### 连接
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| 01000     | 10300       | Circuit break open, the request has been ignored |
-| 08000     | 10301       | Can not get %d connections one time, partition succeed connection(%d) have released. Please consider increasing the \`maxPoolSize\` of the data sources or decreasing the \`max-connections-size-per-query\` in properties |
-| 08000     | 10302       | Connection has been closed |
-| 08000     | 10303       | Result set has been closed |
-| HY000     | 10304       | Load datetime from database failed, reason: %s |
-| HY004     | 10310       | Can not register driver, reason is: %s |
+| 08000     | 13000       | Can not register driver, reason is: %s |
+| 01000     | 13010       | Circuit break open, the request has been ignored |
+| 08000     | 13020       | Can not get %d connections one time, partition succeed connection(%d) have released. Please consider increasing the \`maxPoolSize\` of the data sources or decreasing the \`max-connections-size-per-query\` in properties |
+| 08000     | 13030       | Connection has been closed |
+| 08000     | 13031       | Result set has been closed |
+| HY000     | 13090       | Load datetime from database failed, reason: %s |
 
 ### 事务
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| 25000     | 10400       | Switch transaction type failed, please terminate the current transaction |
-| 25000     | 10401       | Can not start new XA transaction in a active transaction |
-| 25000     | 10402       | Failed to create \`%s\` XA data source |
-| 25000     | 10403       | JDBC does not support operations across multiple logical databases in transaction |
+| 25000     | 14000       | Switch transaction type failed, please terminate the current transaction |
+| 25000     | 14100       | JDBC does not support operations across multiple logical databases in transaction |
+| 25000     | 14200       | Can not start new XA transaction in a active transaction |
+| 25000     | 14201       | Failed to create \`%s\` XA data source |
 
 ### 锁
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| HY000     | 10500       | The table \`%s\` of schema \`%s\` is locked |
-| HY000     | 10501       | The table \`%s\` of schema \`%s\` lock wait timeout of \`%s\` milliseconds exceeded |
+| HY000     | 15000       | The table \`%s\` of schema \`%s\` is locked |
+| HY000     | 15001       | The table \`%s\` of schema \`%s\` lock wait timeout of \`%s\` milliseconds exceeded |
 
 ### 审计
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| 44000     | 10600       | SQL check failed, error message: %s |
+| 44000     | 16000       | SQL check failed, error message: %s |
 
 ### 集群
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| HY000     | 10700       | Work ID assigned failed, which can not exceed 1024 |
-| HY000     | 10701       | Can not find \`%s\` file for datetime initialize |
-| HY000     | 10702       | File access failed, reason is: %s |
+| HY000     | 17000       | Work ID assigned failed, which can not exceed 1024 |
+| HY000     | 17001       | Can not find \`%s\` file for datetime initialize |
+| HY000     | 17002       | File access failed, reason is: %s |
 
 ### 迁移
 
 | SQL State | Vendor Code | 错误信息 |
 | --------- | ----------- | ------ |
-| HY000     | 10800       | Can not find pipeline job \`%s\` |
-| HY000     | 10801       | Failed to get DDL for table \`%s\` |
+| HY000     | 18000       | Can not find pipeline job \`%s\` |
+| HY000     | 18001       | Failed to get DDL for table \`%s\` |
 
 ## 功能异常
 
diff --git a/docs/document/content/user-manual/error-code/sql-error-code.en.md b/docs/document/content/user-manual/error-code/sql-error-code.en.md
index 63c6eb2e90b..7ef9649e71b 100644
--- a/docs/document/content/user-manual/error-code/sql-error-code.en.md
+++ b/docs/document/content/user-manual/error-code/sql-error-code.en.md
@@ -14,24 +14,24 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 
 | SQL State | Vendor Code | Reason |
 | --------- | ----------- | ------ |
+| 42000     | 10000       | Resource does not exist |
 | 08000     | 10001       | The URL \`%s\` is not recognized, please refer to the pattern \`%s\` |
 | 42000     | 10002       | Can not support 3-tier structure for actual data node \`%s\` with JDBC \`%s\` |
-| 42000     | 10003       | Unsupported SQL node conversion for SQL statement \`%s\` |
-| 42000     | 10012       | Resource does not exist |
-| 42000     | 10013       | Rule does not exist |
-| HY004     | 10014       | Invalid format for actual data node \`%s\` |
-| 42S02     | 10020       | Single table \`%s\` does not exist |
-| 42S02     | 10021       | Schema \`%s\` does not exist |
+| HY004     | 10003       | Invalid format for actual data node \`%s\` |
+| 42000     | 10004       | Unsupported SQL node conversion for SQL statement \`%s\` |
+| 42000     | 10010       | Rule does not exist |
+| 42S02     | 10020       | Schema \`%s\` does not exist |
+| 42S02     | 10021       | Single table \`%s\` does not exist |
 | HY000     | 10022       | Can not load table with database name \`%s\` and data source name \`%s\` |
-| 0A000     | 10023       | Can not drop schema \`%s\` because of contains tables |
+| 0A000     | 11030       | Can not drop schema \`%s\` because of contains tables |
 
 ### Data
 
 | SQL State | Vendor Code | Reason |
 | --------- | ----------- | ------ |
-| HY004     | 11001       | Invalid value \`%s\` |
-| HY004     | 11005       | Unsupported conversion stream charset \`%s\` |
-| HY004     | 11006       | Unsupported conversion data type \`%s\` for value \`%s\` |
+| HY004     | 11000       | Invalid value \`%s\` |
+| HY004     | 11001       | Unsupported conversion data type \`%s\` for value \`%s\` |
+| HY004     | 11010       | Unsupported conversion stream charset \`%s\` |
 
 ### Syntax
 
@@ -40,29 +40,29 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
 | 42000     | 12000       | You have an error in your SQL syntax: %s |
 | 42000     | 12001       | SQL String can not be NULL or empty |
 | 42000     | 12002       | Could not support variable \`%s\` |
-| 0A000     | 12003       | DROP TABLE ... CASCADE is not supported |
-| 42S02     | 12004       | Can not find column label \`%s\` |
-| HV008     | 12005       | Column index \`%d\` is out of range |
+| 42S02     | 12003       | Can not find column label \`%s\` |
+| HV008     | 12004       | Column index \`%d\` is out of range |
+| 0A000     | 12010       | DROP TABLE ... CASCADE is not supported |
 
 ### Connection
 
 | SQL State | Vendor Code | Reason |
 | --------- | ----------- | ------ |
-| 01000     | 13000       | Circuit break open, the request has been ignored |
-| 08000     | 13001       | Can not get %d connections one time, partition succeed connection(%d) have released. Please consider increasing the \`maxPoolSize\` of the data sources or decreasing the \`max-connections-size-per-query\` in properties |
-| 08000     | 13002       | Connection has been closed |
-| 08000     | 13003       | Result set has been closed |
-| HY000     | 13004       | Load datetime from database failed, reason: %s |
-| HY004     | 13010       | Can not register driver, reason is: %s |
+| 08000     | 13000       | Can not register driver, reason is: %s |
+| 01000     | 13010       | Circuit break open, the request has been ignored |
+| 08000     | 13020       | Can not get %d connections one time, partition succeed connection(%d) have released. Please consider increasing the \`maxPoolSize\` of the data sources or decreasing the \`max-connections-size-per-query\` in properties |
+| 08000     | 13030       | Connection has been closed |
+| 08000     | 13031       | Result set has been closed |
+| HY000     | 13090       | Load datetime from database failed, reason: %s |
 
 ### Transaction
 
 | SQL State | Vendor Code | Reason |
 | --------- | ----------- | ------ |
 | 25000     | 14000       | Switch transaction type failed, please terminate the current transaction |
-| 25000     | 14001       | Can not start new XA transaction in a active transaction |
-| 25000     | 14002       | Failed to create \`%s\` XA data source |
-| 25000     | 14003       | JDBC does not support operations across multiple logical databases in transaction |
+| 25000     | 14100       | JDBC does not support operations across multiple logical databases in transaction |
+| 25000     | 14200       | Can not start new XA transaction in a active transaction |
+| 25000     | 14201       | Failed to create \`%s\` XA data source |
 
 ### Lock
 
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/InvalidDataNodesFormatException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/InvalidDataNodesFormatException.java
index 5369fdd7b53..196eb5e06a1 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/InvalidDataNodesFormatException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/InvalidDataNodesFormatException.java
@@ -27,6 +27,6 @@ public final class InvalidDataNodesFormatException extends MetaDataSQLException
     private static final long serialVersionUID = 192279170808654743L;
     
     public InvalidDataNodesFormatException(final String dataNode) {
-        super(XOpenSQLState.INVALID_DATA_TYPE, 14, "Invalid format for actual data node `%s`", dataNode);
+        super(XOpenSQLState.INVALID_DATA_TYPE, 3, "Invalid format for actual data node `%s`", dataNode);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/OverallConnectionNotEnoughException.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/OverallConnectionNotEnoughException.java
index 4d74007de8a..a1a793e36d9 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/OverallConnectionNotEnoughException.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/exception/OverallConnectionNotEnoughException.java
@@ -27,7 +27,7 @@ public final class OverallConnectionNotEnoughException extends ConnectionSQLExce
     private static final long serialVersionUID = -1297088138042287804L;
     
     public OverallConnectionNotEnoughException(final int desiredSize, final int actualSize) {
-        super(XOpenSQLState.CONNECTION_EXCEPTION, 1, "Can not get %d connections one time, partition succeed connection(%d) have released. "
+        super(XOpenSQLState.CONNECTION_EXCEPTION, 20, "Can not get %d connections one time, partition succeed connection(%d) have released. "
                 + "Please consider increasing the `maxPoolSize` of the data sources or decreasing the `max-connections-size-per-query` in properties", desiredSize, actualSize);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
index 77fd46f23db..4c5233cae72 100644
--- a/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/DatetimeLoadingException.java
@@ -30,6 +30,6 @@ public final class DatetimeLoadingException extends ConnectionSQLException {
     private static final long serialVersionUID = 7844267165522132993L;
     
     public DatetimeLoadingException(final SQLException cause) {
-        super(XOpenSQLState.GENERAL_ERROR, 4, "Load datetime from database failed, reason: %s", cause.getMessage());
+        super(XOpenSQLState.GENERAL_ERROR, 90, "Load datetime from database failed, reason: %s", cause.getMessage());
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedDataTypeConversionException.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedDataTypeConversionException.java
index 1b8c3ab28af..277ac16c1d8 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedDataTypeConversionException.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedDataTypeConversionException.java
@@ -30,6 +30,6 @@ public final class UnsupportedDataTypeConversionException extends DataSQLExcepti
     private static final long serialVersionUID = 4808672149254705863L;
     
     public UnsupportedDataTypeConversionException(final Class<?> convertType, final Object value) {
-        super(XOpenSQLState.INVALID_DATA_TYPE, 6, "Unsupported conversion data type `%s` for value `%s`", convertType.getName(), Objects.toString(value));
+        super(XOpenSQLState.INVALID_DATA_TYPE, 1, "Unsupported conversion data type `%s` for value `%s`", convertType.getName(), Objects.toString(value));
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedStreamCharsetConversionException.java b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedStreamCharsetConversionException.java
index 9a9e45d5e81..be31c7b7e49 100644
--- a/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedStreamCharsetConversionException.java
+++ b/shardingsphere-infra/shardingsphere-infra-executor/src/main/java/org/apache/shardingsphere/infra/executor/exception/UnsupportedStreamCharsetConversionException.java
@@ -28,6 +28,6 @@ public final class UnsupportedStreamCharsetConversionException extends DataSQLEx
     private static final long serialVersionUID = 4577091201937095156L;
     
     public UnsupportedStreamCharsetConversionException(final String charsetType) {
-        super(XOpenSQLState.INVALID_DATA_TYPE, 5, "Unsupported conversion stream charset `%s`", charsetType);
+        super(XOpenSQLState.INVALID_DATA_TYPE, 10, "Unsupported conversion stream charset `%s`", charsetType);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLException.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLException.java
index da25457b826..10b73d5d6a2 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLException.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLException.java
@@ -30,6 +30,6 @@ public abstract class KernelSQLException extends ShardingSphereSQLException {
     private static final int TYPE_OFFSET = 1;
     
     public KernelSQLException(final SQLState sqlState, final int kernelCode, final int errorCode, final String reason, final Object... messageArguments) {
-        super(sqlState, TYPE_OFFSET, kernelCode * 100 + errorCode, reason, messageArguments);
+        super(sqlState, TYPE_OFFSET, kernelCode * 1000 + errorCode, reason, messageArguments);
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLExceptionTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLExceptionTest.java
index a85bc5e055a..d06d0006e90 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLExceptionTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/external/sql/type/kernel/KernelSQLExceptionTest.java
@@ -29,21 +29,11 @@ public final class KernelSQLExceptionTest {
     
     @SuppressWarnings("serial")
     @Test
-    public void assertNewKernelSQLExceptionSQLExceptionWithSingleDigitalForKernelCode() {
+    public void assertNewKernelSQLExceptionSQLException() {
         SQLException actual = new KernelSQLException(XOpenSQLState.GENERAL_ERROR, 1, 1, "reason") {
         }.toSQLException();
         assertThat(actual.getSQLState(), is(XOpenSQLState.GENERAL_ERROR.getValue()));
-        assertThat(actual.getErrorCode(), is(10101));
-        assertThat(actual.getMessage(), is("reason"));
-    }
-    
-    @SuppressWarnings("serial")
-    @Test
-    public void assertNewKernelSQLExceptionSQLExceptionWithDoubleDigitalForKernelCode() {
-        SQLException actual = new KernelSQLException(XOpenSQLState.GENERAL_ERROR, 99, 10, "reason") {
-        }.toSQLException();
-        assertThat(actual.getSQLState(), is(XOpenSQLState.GENERAL_ERROR.getValue()));
-        assertThat(actual.getErrorCode(), is(19910));
+        assertThat(actual.getErrorCode(), is(11001));
         assertThat(actual.getMessage(), is("reason"));
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/DriverRegisterException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/DriverRegisterException.java
index d73018db73c..d8b3afa546e 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/DriverRegisterException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/DriverRegisterException.java
@@ -30,6 +30,6 @@ public final class DriverRegisterException extends ConnectionSQLException {
     private static final long serialVersionUID = -8091239932993280564L;
     
     public DriverRegisterException(final SQLException cause) {
-        super(XOpenSQLState.GENERAL_ERROR, 10, "Can not register driver, reason is: %s", cause.getMessage());
+        super(XOpenSQLState.CONNECTION_EXCEPTION, 0, "Can not register driver, reason is: %s", cause.getMessage());
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ConnectionClosedException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ConnectionClosedException.java
index 5e90e43b4de..a877b91ae4b 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ConnectionClosedException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ConnectionClosedException.java
@@ -28,6 +28,6 @@ public final class ConnectionClosedException extends ConnectionSQLException {
     private static final long serialVersionUID = 8667898851939815681L;
     
     public ConnectionClosedException() {
-        super(XOpenSQLState.CONNECTION_EXCEPTION, 2, "Connection has been closed");
+        super(XOpenSQLState.CONNECTION_EXCEPTION, 30, "Connection has been closed");
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ResultSetClosedException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ResultSetClosedException.java
index 5e2933feb1e..ca4718e3eba 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ResultSetClosedException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/connection/ResultSetClosedException.java
@@ -28,6 +28,6 @@ public final class ResultSetClosedException extends ConnectionSQLException {
     private static final long serialVersionUID = 3931974854134322934L;
     
     public ResultSetClosedException() {
-        super(XOpenSQLState.CONNECTION_EXCEPTION, 3, "Result set has been closed");
+        super(XOpenSQLState.CONNECTION_EXCEPTION, 31, "Result set has been closed");
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnIndexOutOfRangeException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnIndexOutOfRangeException.java
index a8668bc7704..705f1b56fc5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnIndexOutOfRangeException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnIndexOutOfRangeException.java
@@ -28,6 +28,6 @@ public final class ColumnIndexOutOfRangeException extends SyntaxSQLException {
     private static final long serialVersionUID = 3599337605134702447L;
     
     public ColumnIndexOutOfRangeException(final int columnIndex) {
-        super(XOpenSQLState.INVALID_COLUMN_NUMBER, 5, "Column index `%d` is out of range", columnIndex);
+        super(XOpenSQLState.INVALID_COLUMN_NUMBER, 4, "Column index `%d` is out of range", columnIndex);
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnLabelNotFoundException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnLabelNotFoundException.java
index 47468e8f5a2..1241d4d70ab 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnLabelNotFoundException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/syntax/ColumnLabelNotFoundException.java
@@ -28,6 +28,6 @@ public final class ColumnLabelNotFoundException extends SyntaxSQLException {
     private static final long serialVersionUID = -4634399403612501335L;
     
     public ColumnLabelNotFoundException(final String columnLabel) {
-        super(XOpenSQLState.NOT_FOUND, 4, "Can not find column label `%s`", columnLabel);
+        super(XOpenSQLState.NOT_FOUND, 3, "Can not find column label `%s`", columnLabel);
     }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
index 10e2acfb8a1..9e7c6a3e06e 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/transaction/JDBCTransactionAcrossDatabasesException.java
@@ -28,6 +28,6 @@ public final class JDBCTransactionAcrossDatabasesException extends TransactionSQ
     private static final long serialVersionUID = 3294968323117604702L;
     
     public JDBCTransactionAcrossDatabasesException() {
-        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 3, "JDBC does not support operations across multiple logical databases in transaction");
+        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 100, "JDBC does not support operations across multiple logical databases in transaction");
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
index 3f76d58d491..d12707e7721 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/DropNotEmptySchemaException.java
@@ -28,6 +28,6 @@ public final class DropNotEmptySchemaException extends MetaDataSQLException {
     private static final long serialVersionUID = 5285619119572894557L;
     
     public DropNotEmptySchemaException(final String schemaName) {
-        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 23, "Can not drop schema `%s` because of contains tables", schemaName);
+        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 30, "Can not drop schema `%s` because of contains tables", schemaName);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SchemaNotFoundException.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SchemaNotFoundException.java
index 5c2825b22b3..31987c2e926 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SchemaNotFoundException.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SchemaNotFoundException.java
@@ -28,6 +28,6 @@ public final class SchemaNotFoundException extends MetaDataSQLException {
     private static final long serialVersionUID = 2722045034640737328L;
     
     public SchemaNotFoundException(final String schemaName) {
-        super(XOpenSQLState.NOT_FOUND, 21, "Schema `%s` does not exist", schemaName);
+        super(XOpenSQLState.NOT_FOUND, 20, "Schema `%s` does not exist", schemaName);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTableNotFoundException.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTableNotFoundException.java
index 2d8705d9595..214628ea57c 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTableNotFoundException.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/SingleTableNotFoundException.java
@@ -28,6 +28,6 @@ public final class SingleTableNotFoundException extends MetaDataSQLException {
     private static final long serialVersionUID = 3498790429190415298L;
     
     public SingleTableNotFoundException(final String tableName) {
-        super(XOpenSQLState.NOT_FOUND, 20, "Single table `%s` does not exist", tableName);
+        super(XOpenSQLState.NOT_FOUND, 21, "Single table `%s` does not exist", tableName);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/UnsupportedDropCascadeTableException.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/UnsupportedDropCascadeTableException.java
index 1f5940c06c7..11c67d728f9 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/UnsupportedDropCascadeTableException.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/exception/UnsupportedDropCascadeTableException.java
@@ -28,6 +28,6 @@ public final class UnsupportedDropCascadeTableException extends SyntaxSQLExcepti
     private static final long serialVersionUID = -5995575055241171117L;
     
     public UnsupportedDropCascadeTableException() {
-        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 3, "DROP TABLE ... CASCADE is not supported");
+        super(XOpenSQLState.FEATURE_NOT_SUPPORTED, 10, "DROP TABLE ... CASCADE is not supported");
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/exception/OptimizationSQLNodeConvertException.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/exception/OptimizationSQLNodeConvertException.java
index 8edae77de35..d7cdb8279dc 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/exception/OptimizationSQLNodeConvertException.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/exception/OptimizationSQLNodeConvertException.java
@@ -29,6 +29,6 @@ public final class OptimizationSQLNodeConvertException extends MetaDataSQLExcept
     private static final long serialVersionUID = -5486229929620713984L;
     
     public OptimizationSQLNodeConvertException(final SQLStatement statement) {
-        super(XOpenSQLState.SYNTAX_ERROR, 3, "Unsupported SQL node conversion for SQL statement `%s`", statement.toString());
+        super(XOpenSQLState.SYNTAX_ERROR, 4, "Unsupported SQL node conversion for SQL statement `%s`", statement.toString());
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourc [...]
index d37cd7d76b9..36e9f650401 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XADataSourceInitializeException.java
@@ -29,6 +29,6 @@ public final class XADataSourceInitializeException extends TransactionSQLExcepti
     private static final long serialVersionUID = -4515239569528215614L;
     
     public XADataSourceInitializeException(final XADataSourceDefinition xaDataSourceDefinition) {
-        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 2, "Failed to create `%s` XA data source", xaDataSourceDefinition.getType());
+        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 201, "Failed to create `%s` XA data source", xaDataSourceDefinition.getType());
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XATransactionNestedBeginException.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XATransac [...]
index a8111d3258f..93d06519b1a 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XATransactionNestedBeginException.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/exception/XATransactionNestedBeginException.java
@@ -28,6 +28,6 @@ public final class XATransactionNestedBeginException extends TransactionSQLExcep
     private static final long serialVersionUID = 7761100591709104351L;
     
     public XATransactionNestedBeginException() {
-        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 1, "Can not start new XA transaction in a active transaction");
+        super(XOpenSQLState.INVALID_TRANSACTION_STATE, 200, "Can not start new XA transaction in a active transaction");
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidValueException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidValueException.java
index dd6b621b49b..f490ca66064 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidValueException.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/InvalidValueException.java
@@ -28,6 +28,6 @@ public final class InvalidValueException extends DataSQLException {
     private static final long serialVersionUID = 1840341880422454371L;
     
     public InvalidValueException(final String value) {
-        super(XOpenSQLState.INVALID_DATA_TYPE, 1, "Invalid value `%s`", value);
+        super(XOpenSQLState.INVALID_DATA_TYPE, 0, "Invalid value `%s`", value);
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/ResourceNotExistedException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/ResourceNotExistedException.java
index 4e67c921620..c94d2fd243b 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/ResourceNotExistedException.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/ResourceNotExistedException.java
@@ -28,6 +28,6 @@ public final class ResourceNotExistedException extends MetaDataSQLException {
     private static final long serialVersionUID = 4146100333670404924L;
     
     public ResourceNotExistedException() {
-        super(XOpenSQLState.SYNTAX_ERROR, 12, "Resource does not exist");
+        super(XOpenSQLState.SYNTAX_ERROR, 0, "Resource does not exist");
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/RuleNotExistedException.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/RuleNotExistedException.java
index 1f53e7639e1..4ab30a93ce8 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/RuleNotExistedException.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/exception/RuleNotExistedException.java
@@ -28,6 +28,6 @@ public final class RuleNotExistedException extends MetaDataSQLException {
     private static final long serialVersionUID = -4150905802300104824L;
     
     public RuleNotExistedException() {
-        super(XOpenSQLState.SYNTAX_ERROR, 13, "Rule does not exist");
+        super(XOpenSQLState.SYNTAX_ERROR, 10, "Rule does not exist");
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/CircuitBreakException.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/CircuitBreakException.java
index 4c6ab166198..1166c8597cd 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/CircuitBreakException.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-core/src/main/java/org/apache/shardingsphere/proxy/frontend/exception/CircuitBreakException.java
@@ -28,6 +28,6 @@ public final class CircuitBreakException extends ConnectionSQLException {
     private static final long serialVersionUID = 6339672680026286798L;
     
     public CircuitBreakException() {
-        super(XOpenSQLState.GENERAL_WARNING, 0, "Circuit break open, the request has been ignored");
+        super(XOpenSQLState.GENERAL_WARNING, 10, "Circuit break open, the request has been ignored");
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
index 0da54ded70f..284a1a42172 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/test/java/org/apache/shardingsphere/proxy/frontend/mysql/err/MySQLErrPacketFactoryTest.java
@@ -53,7 +53,7 @@ public final class MySQLErrPacketFactoryTest {
     public void assertNewInstanceWithShardingSphereSQLException() {
         MySQLErrPacket actual = MySQLErrPacketFactory.newInstance(new CircuitBreakException());
         assertThat(actual.getSequenceId(), is(1));
-        assertThat(actual.getErrorCode(), is(10300));
+        assertThat(actual.getErrorCode(), is(13010));
         assertThat(actual.getSqlState(), is(XOpenSQLState.GENERAL_WARNING.getValue()));
         assertThat(actual.getErrorMessage(), is("Circuit break open, the request has been ignored"));
     }