You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ja...@apache.org on 2023/12/07 10:54:23 UTC
(iotdb) branch JDBCReconnect created (now d211a392efa)
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a change to branch JDBCReconnect
in repository https://gitbox.apache.org/repos/asf/iotdb.git
at d211a392efa Support reconnect for JDBC
This branch includes the following new commits:
new d211a392efa Support reconnect for JDBC
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(iotdb) 01/01: Support reconnect for JDBC
Posted by ja...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch JDBCReconnect
in repository https://gitbox.apache.org/repos/asf/iotdb.git
commit d211a392efa4aa890bd152f66dbd492b5b89e23b
Author: JackieTien97 <ja...@gmail.com>
AuthorDate: Thu Dec 7 18:54:09 2023 +0800
Support reconnect for JDBC
---
.../src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 31bd7a92624..9223502afea 100644
--- a/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/iotdb-client/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -736,9 +736,16 @@ public class IoTDBStatement implements Statement {
}
}
- private void reInit() {
+ private boolean reInit() throws SQLException {
this.client = connection.getClient();
this.sessionId = connection.getSessionId();
+ try {
+ this.stmtId = client.requestStatementId(sessionId);
+ return true;
+ } catch (Exception e) {
+ throw new SQLException(
+ "Cannot get id for statement after reconnecting. please check server status", e);
+ }
}
private void requestStmtId() throws SQLException {
@@ -759,9 +766,9 @@ public class IoTDBStatement implements Statement {
}
}
- private boolean reConnect() {
+ private boolean reConnect() throws SQLException {
boolean flag = connection.reconnect();
- reInit();
+ flag = flag && reInit();
return flag;
}