You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/09/06 04:53:42 UTC
[shardingsphere] branch master updated: Add ConnectionClosedException (#20819)
This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 1e91c2c36a6 Add ConnectionClosedException (#20819)
1e91c2c36a6 is described below
commit 1e91c2c36a63e5e15ad6a4be8633bdda29d7a5d8
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Tue Sep 6 12:53:34 2022 +0800
Add ConnectionClosedException (#20819)
---
.../content/user-manual/error-code/sql-error-code.cn.md | 3 ++-
.../content/user-manual/error-code/sql-error-code.en.md | 3 ++-
.../driver/jdbc/core/connection/ShardingSphereConnection.java | 3 ++-
.../driver/jdbc/exception/ColumnIndexOutOfRangeException.java | 2 +-
.../driver/jdbc/exception/ColumnLabelNotFoundException.java | 2 +-
.../{EmptySQLException.java => ConnectionClosedException.java} | 10 +++++-----
.../driver/jdbc/exception/EmptySQLException.java | 2 +-
.../jdbc/exception/OverallConnectionNotEnoughException.java | 2 +-
.../driver/jdbc/exception/ResultSetClosedException.java | 2 +-
9 files changed, 16 insertions(+), 13 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 51516fdca39..9d572a110f4 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
@@ -25,7 +25,8 @@ SQL 错误码以标准的 SQL State,Vendor Code 和详细错误信息提供,
| HV008 | 10302 | Column index \`%d\` is out of range |
| 42S02 | 10303 | Can not find column label \`%s`\ |
| HY004 | 10400 | Invalid format for actual data node \`%s\` |
-| HY000 | 10500 | Result set has been closed |
+| 08000 | 10500 | Connection has been closed |
+| 08000 | 10501 | Result set has been closed |
| 42000 | 11000 | You have an error in your SQL syntax: %s |
| 42000 | 11002 | Resource does not exist |
| 42000 | 11003 | Rule 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 7122cfe00f4..39eb1167e19 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
@@ -25,7 +25,8 @@ SQL error codes provide by standard `SQL State`, `Vendor Code` and `Reason`, whi
| HV008 | 10302 | Column index \`%d\` is out of range |
| 42S02 | 10303 | Can not find column label \`%s`\ |
| HY004 | 10400 | Invalid format for actual data node \`%s\` |
-| HY000 | 10500 | Result set has been closed |
+| 08000 | 10500 | Connection has been closed |
+| 08000 | 10501 | Result set has been closed |
| 42000 | 11000 | You have an error in your SQL syntax: %s |
| 42000 | 11002 | Resource does not exist |
| 42000 | 11003 | Rule does not exist |
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
index 8ca65e194d6..5be5022f233 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/connection/ShardingSphereConnection.java
@@ -23,6 +23,7 @@ import org.apache.shardingsphere.driver.jdbc.context.JDBCContext;
import org.apache.shardingsphere.driver.jdbc.core.datasource.metadata.ShardingSphereDatabaseMetaData;
import org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSpherePreparedStatement;
import org.apache.shardingsphere.driver.jdbc.core.statement.ShardingSphereStatement;
+import org.apache.shardingsphere.driver.jdbc.exception.ConnectionClosedException;
import org.apache.shardingsphere.infra.context.ConnectionContext;
import org.apache.shardingsphere.mode.manager.ContextManager;
@@ -225,7 +226,7 @@ public final class ShardingSphereConnection extends AbstractConnectionAdapter {
private void checkClose() throws SQLException {
if (isClosed()) {
- throw new SQLException("This connection has been closed");
+ throw new ConnectionClosedException().toSQLException();
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnIndexOutOfRangeException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnIndexOutOfRangeException.java
index b670c160244..9bd5c9ea9c7 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnIndexOutOfRangeException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnIndexOutOfRangeException.java
@@ -28,6 +28,6 @@ public final class ColumnIndexOutOfRangeException extends ShardingSphereSQLExcep
private static final long serialVersionUID = 3599337605134702447L;
public ColumnIndexOutOfRangeException(final int columnIndex) {
- super(XOpenSQLState.INVALID_COLUMN_NUMBER.getValue(), 10302, "Column index `%d` is out of range", columnIndex);
+ super(XOpenSQLState.INVALID_COLUMN_NUMBER, 10302, "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/ColumnLabelNotFoundException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnLabelNotFoundException.java
index f3ceb10b887..a33b2bb361d 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnLabelNotFoundException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ColumnLabelNotFoundException.java
@@ -28,6 +28,6 @@ public final class ColumnLabelNotFoundException extends ShardingSphereSQLExcepti
private static final long serialVersionUID = -4634399403612501335L;
public ColumnLabelNotFoundException(final String columnLabel) {
- super(XOpenSQLState.NOT_FOUND.getValue(), 10303, "Can not find column label `%s`", columnLabel);
+ super(XOpenSQLState.NOT_FOUND, 10303, "Can not find column label `%s`", columnLabel);
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ConnectionClosedException.java
similarity index 77%
copy from shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java
copy to shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ConnectionClosedException.java
index e8aaff46780..06362465cf3 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ConnectionClosedException.java
@@ -21,13 +21,13 @@ import org.apache.shardingsphere.infra.util.exception.external.sql.ShardingSpher
import org.apache.shardingsphere.infra.util.exception.external.sql.sqlstate.XOpenSQLState;
/**
- * Empty SQL exception.
+ * Connection closed exception.
*/
-public final class EmptySQLException extends ShardingSphereSQLException {
+public final class ConnectionClosedException extends ShardingSphereSQLException {
- private static final long serialVersionUID = -5723825491720138339L;
+ private static final long serialVersionUID = 8667898851939815681L;
- public EmptySQLException() {
- super(XOpenSQLState.GENERAL_ERROR.getValue(), 10006, "SQL String can not be NULL or empty");
+ public ConnectionClosedException() {
+ super(XOpenSQLState.CONNECTION_EXCEPTION, 10500, "Connection has been closed");
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java
index e8aaff46780..6a93721f3a5 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/EmptySQLException.java
@@ -28,6 +28,6 @@ public final class EmptySQLException extends ShardingSphereSQLException {
private static final long serialVersionUID = -5723825491720138339L;
public EmptySQLException() {
- super(XOpenSQLState.GENERAL_ERROR.getValue(), 10006, "SQL String can not be NULL or empty");
+ super(XOpenSQLState.GENERAL_ERROR, 10006, "SQL String can not be NULL or empty");
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/OverallConnectionNotEnoughException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/OverallConnectionNotEnoughException.java
index 6d07d8b6372..0ad901620fe 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/OverallConnectionNotEnoughException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/OverallConnectionNotEnoughException.java
@@ -28,6 +28,6 @@ public final class OverallConnectionNotEnoughException extends ShardingSphereSQL
private static final long serialVersionUID = -1297088138042287804L;
public OverallConnectionNotEnoughException(final int desiredSize, final int actualSize) {
- super(XOpenSQLState.CONNECTION_EXCEPTION.getValue(), 10007, "Can not get %d connections one time, partition succeed connection(%d) have released", desiredSize, actualSize);
+ super(XOpenSQLState.CONNECTION_EXCEPTION, 10007, "Can not get %d connections one time, partition succeed connection(%d) have released", desiredSize, actualSize);
}
}
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ResultSetClosedException.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ResultSetClosedException.java
index ca179f2b52b..e7c296a7b52 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ResultSetClosedException.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/exception/ResultSetClosedException.java
@@ -28,6 +28,6 @@ public final class ResultSetClosedException extends ShardingSphereSQLException {
private static final long serialVersionUID = 3931974854134322934L;
public ResultSetClosedException() {
- super(XOpenSQLState.GENERAL_ERROR.getValue(), 10500, "Result set has been closed");
+ super(XOpenSQLState.CONNECTION_EXCEPTION, 10501, "Result set has been closed");
}
}