[IOTDB-300]reconnection to requestStmtId when broke pip (#543)

This commit is contained in:
Dawei Liu 2019-11-16 14:37:25 +08:00 committed by Jialin Qiao
parent d8415e9ab8
commit ef16fad43a
1 changed files with 23 additions and 13 deletions

View File

@ -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;
}
}