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

rong pushed a commit to branch iotdb-1506
in repository https://gitbox.apache.org/repos/asf/iotdb.git

commit cff1006abb494118b071115529080d529424aa6e
Author: Steve Yurong Su <[email protected]>
AuthorDate: Thu Jul 15 17:37:06 2021 +0800

    [IOTDB-1506] CI fails because of JDBC connection exceptions
---
 .../db/integration/IoTDBContinuousQueryIT.java     | 43 +++++++++++++++-------
 .../db/integration/IoTDBTriggerExecutionIT.java    | 43 +++++++++++++++++-----
 2 files changed, 64 insertions(+), 22 deletions(-)

diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBContinuousQueryIT.java
 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBContinuousQueryIT.java
index c72c04e..b374ed2 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBContinuousQueryIT.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBContinuousQueryIT.java
@@ -30,7 +30,11 @@ import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.sql.*;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.List;
@@ -57,21 +61,34 @@ public class IoTDBContinuousQueryIT {
         @Override
         public void run() {
 
-          try (Connection connection =
-                  DriverManager.getConnection(
-                      Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
-              Statement statement = connection.createStatement()) {
+          try {
+            Connection connection =
+                DriverManager.getConnection(
+                    Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
+            Statement statement = connection.createStatement();
 
             do {
-
               for (String timeSeries : timeSeriesArray) {
-                try {
-                  statement.execute(
-                      String.format(
-                          "insert into %s(timestamp, temperature) 
values(now(), %.3f)",
-                          timeSeries, 200 * Math.random()));
-                } catch (SQLException throwables) {
-                  LOGGER.error(throwables.getMessage());
+                boolean isSuccessful = false;
+                while (!isSuccessful) {
+                  try {
+                    statement.execute(
+                        String.format(
+                            "insert into %s(timestamp, temperature) 
values(now(), %.3f)",
+                            timeSeries, 200 * Math.random()));
+                    isSuccessful = true;
+                  } catch (SQLException throwable) {
+                    LOGGER.error(throwable.getMessage());
+                    throwable.printStackTrace();
+
+                    statement.close();
+                    connection.close();
+
+                    connection =
+                        DriverManager.getConnection(
+                            Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", 
"root", "root");
+                    statement = connection.createStatement();
+                  }
                 }
               }
             } while (!isInterrupted());
diff --git 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
index 2b55143..ef5ab2f 100644
--- 
a/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
+++ 
b/server/src/test/java/org/apache/iotdb/db/integration/IoTDBTriggerExecutionIT.java
@@ -61,19 +61,44 @@ public class IoTDBTriggerExecutionIT {
         @Override
         public void run() {
 
-          try (Connection connection =
-                  DriverManager.getConnection(
-                      Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
-              Statement statement = connection.createStatement()) {
+          try {
+            Connection connection =
+                DriverManager.getConnection(
+                    Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
+            Statement statement = connection.createStatement();
+
             long count = 0;
             do {
               ++count;
-              statement.execute(
-                  String.format(
-                      "insert into 
root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6) values(%d,%d,%d,%d,%d,%s,\"%d\")",
-                      count, count, count, count, count, count % 2 == 0 ? 
"true" : "false", count));
+              boolean isSuccessful = false;
+              while (!isSuccessful) {
+                try {
+                  statement.execute(
+                      String.format(
+                          "insert into 
root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6) values(%d,%d,%d,%d,%d,%s,\"%d\")",
+                          count,
+                          count,
+                          count,
+                          count,
+                          count,
+                          count % 2 == 0 ? "true" : "false",
+                          count));
+                  isSuccessful = true;
+                } catch (SQLException throwable) {
+                  LOGGER.error(throwable.getMessage());
+                  throwable.printStackTrace();
+
+                  statement.close();
+                  connection.close();
+
+                  connection =
+                      DriverManager.getConnection(
+                          Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", 
"root");
+                  statement = connection.createStatement();
+                }
+              }
             } while (!isInterrupted());
-          } catch (SQLException e) {
+          } catch (Exception e) {
             exception = e;
           }
         }

Reply via email to