You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/11/16 06:37:30 UTC
[incubator-iotdb] branch master updated: [IOTDB-300]reconnection to
requestStmtId when broke pip (#543)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new ef16fad [IOTDB-300]reconnection to requestStmtId when broke pip (#543)
ef16fad is described below
commit ef16fad43aff6e907539cf6a2ec76c6433b969ad
Author: Dawei Liu <13...@qq.com>
AuthorDate: Sat Nov 16 14:37:25 2019 +0800
[IOTDB-300]reconnection to requestStmtId when broke pip (#543)
---
.../java/org/apache/iotdb/jdbc/IoTDBStatement.java | 36 ++++++++++++++--------
1 file changed, 23 insertions(+), 13 deletions(-)
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
index 481bcaf..ee7ded2 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBStatement.java
@@ -196,9 +196,7 @@ public class IoTDBStatement implements Statement {
try {
return executeSQL(sql);
} catch (TException e) {
- boolean flag = connection.reconnect();
- reInit();
- if (flag) {
+ if (reConnect()) {
try {
return executeSQL(sql);
} catch (TException e2) {
@@ -337,9 +335,7 @@ public class IoTDBStatement implements Statement {
try {
return executeBatchSQL();
} catch (TException e) {
- boolean flag = connection.reconnect();
- reInit();
- if (flag) {
+ if (reConnect()) {
try {
return executeBatchSQL();
} catch (TException e2) {
@@ -394,9 +390,7 @@ public class IoTDBStatement implements Statement {
try {
return executeQuerySQL(sql);
} catch (TException e) {
- boolean flag = connection.reconnect();
- reInit();
- if (flag) {
+ if (reConnect()) {
try {
return executeQuerySQL(sql);
} catch (TException e2) {
@@ -434,9 +428,7 @@ public class IoTDBStatement implements Statement {
try {
return executeUpdateSQL(sql);
} catch (TException e) {
- boolean flag = connection.reconnect();
- reInit();
- if (flag) {
+ if (reConnect()) {
try {
return executeUpdateSQL(sql);
} catch (TException e2) {
@@ -644,7 +636,25 @@ public class IoTDBStatement implements Statement {
try {
this.stmtId = client.requestStatementId();
} catch (TException e) {
- throw new SQLException("Cannot get id for statement", e);
+ if (reConnect()) {
+ try {
+ this.stmtId = client.requestStatementId();
+ } catch (TException e2) {
+ throw new SQLException(
+ "Cannot get id for statement after reconnecting. please check server status",
+ e2);
+ }
+ } else {
+ throw new SQLException(
+ "Cannot get id for statement after reconnecting. please check server status", e);
+ }
}
}
+
+
+ private boolean reConnect(){
+ boolean flag = connection.reconnect();
+ reInit();
+ return flag;
+ }
}