Browse Source

更新失败则自动建表更新---优化

xushili 2 years ago
parent
commit
f2e9240b02
1 changed files with 6 additions and 5 deletions
  1. 6 5
      src/main/java/com/gyee/redis2taos/service/TaskInsert2Taos.java

+ 6 - 5
src/main/java/com/gyee/redis2taos/service/TaskInsert2Taos.java

@@ -31,17 +31,18 @@ public class TaskInsert2Taos implements Runnable {
             sql = sql.replaceFirst("INSERT INTO ", "CREATE TABLE IF NOT EXISTS ");
             sql = sql.replaceAll("VALUES.+?\\) ", replace);
             sql = sql.replace(",CREATE TABLE IF NOT EXISTS ;", "");*/
-            sql = sql.replaceAll("\\) ", ");~INSERT INTO ");
+            /*sql = sql.replaceAll("\\) ", ");~INSERT INTO ");
             sql = sql.replaceAll("VALUES", replace);
-            sql = sql.replaceAll("~INSERT INTO ;", "");
-            String ss = null;
+            sql = sql.replaceAll("~INSERT INTO ;", "");*/
+            String ss = sql.replace("VALUES", replace);
             try {
                 Statement st = conn.createStatement();
-                String[] split = sql.split("~");
+                /*String[] split = sql.split("~");
                 for (String s : split) {
                     ss = s;
                     st.executeUpdate(s);
-                }
+                }*/
+                st.executeUpdate(ss);
             } catch (Exception ex) {
                 ex.printStackTrace();
                 log.error(ss);