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

panjuan 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 f7c3646aa54 Add DriverRegisterException (#20462)
f7c3646aa54 is described below

commit f7c3646aa5430d78dd37b564c34fe481c7ac1cd2
Author: Liang Zhang <[email protected]>
AuthorDate: Tue Aug 23 18:34:59 2022 +0800

    Add DriverRegisterException (#20462)
---
 .../user-manual/error-code/sql-error-code.cn.md    |  1 +
 .../user-manual/error-code/sql-error-code.en.md    |  1 +
 .../driver/DriverRegisterException.java            | 35 ++++++++++++++++++++++
 .../driver/ShardingSphereDriver.java               |  3 +-
 4 files changed, 38 insertions(+), 2 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 e7798bebcfb..ea987845f48 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
@@ -13,6 +13,7 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
 | 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\` |
 | HY004     | 10004       | Unsupported conversion data type \`%s\` for value 
\`%s\` |
+| HY004     | 10100       | Can not register driver, reason is: %s |
 | 42000     | 11000       | You have an error in your SQL syntax: %s |
 | 42000     | 11001       | configuration error |
 | 42000     | 11002       | Resource does not exist |
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 7502eef883b..21059e12c99 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
@@ -13,6 +13,7 @@ SQL error codes provide by standard `SQL State`, `Vendor 
Code` and `Reason`, whi
 | 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\` |
 | HY004     | 10004       | Unsupported conversion data type \`%s\` for value 
\`%s\` |
+| HY004     | 10100       | Can not register driver, reason is: %s |
 | 42000     | 11000       | You have an error in your SQL syntax: %s |
 | 42000     | 11001       | configuration error |
 | 42000     | 11002       | Resource does not exist |
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
new file mode 100644
index 00000000000..ce229d0f0ec
--- /dev/null
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/DriverRegisterException.java
@@ -0,0 +1,35 @@
+/*
+ * 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.shardingsphere.driver;
+
+import 
org.apache.shardingsphere.infra.util.exception.sql.ShardingSphereSQLException;
+import 
org.apache.shardingsphere.infra.util.exception.sql.sqlstate.XOpenSQLState;
+
+import java.sql.SQLException;
+
+/**
+ * Driver register exception.
+ */
+public final class DriverRegisterException extends ShardingSphereSQLException {
+    
+    private static final long serialVersionUID = -8091239932993280564L;
+    
+    public DriverRegisterException(final SQLException cause) {
+        super(XOpenSQLState.GENERAL_ERROR, 10100, "Can not register driver, 
reason is: %s", cause.getMessage());
+    }
+}
diff --git 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
index b386ab88174..0f147a28bb1 100644
--- 
a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
+++ 
b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/ShardingSphereDriver.java
@@ -18,7 +18,6 @@
 package org.apache.shardingsphere.driver;
 
 import org.apache.shardingsphere.driver.jdbc.core.driver.DriverDataSourceCache;
-import org.apache.shardingsphere.infra.exception.ShardingSphereException;
 
 import java.sql.Connection;
 import java.sql.Driver;
@@ -43,7 +42,7 @@ public final class ShardingSphereDriver implements Driver {
         try {
             DriverManager.registerDriver(new ShardingSphereDriver());
         } catch (final SQLException ex) {
-            throw new ShardingSphereException("Can not register driver.", ex);
+            throw new DriverRegisterException(ex);
         }
     }
     

Reply via email to