فهرست منبع

phoenix的 upsert and delete

wudianlong 3 سال پیش
والد
کامیت
4c23af9a20
1فایلهای تغییر یافته به همراه14 افزوده شده و 10 حذف شده
  1. 14 10
      dw-db/src/main/java/com/saga/hbase/phoenix/app/PhoenixDML.java

+ 14 - 10
dw-db/src/main/java/com/saga/hbase/phoenix/app/PhoenixDML.java

@@ -27,7 +27,7 @@ public class PhoenixDML {
 
     public static void main(String[] args) throws ClassNotFoundException, SQLException {
 
-        select("", "");
+        delete();
         closeConnection();
     }
 
@@ -52,14 +52,14 @@ public class PhoenixDML {
     }
 
     //TODO 更新插入
-    public Integer upsert(){
-        String sql1="upsert into test_phoenix_api values(1,'test1')";
-        String sql2="upsert into test_phoenix_api values(2,'test2')";
-        String sql3="upsert into test_phoenix_api values(3,'test3')";
-//        stat.executeUpdate(sql1);
-//        stat.executeUpdate(sql2);
-//        stat.executeUpdate(sql3);
-//        conn.commit();
+    public static Integer upsert() throws SQLException {
+        String sql1="upsert into SAGA_LOG.test_phoenix_api values(1,'test1')";
+        String sql2="upsert into SAGA_LOG.test_phoenix_api values(2,'test2')";
+        String sql3="upsert into SAGA_LOG.test_phoenix_api values(3,'test3')";
+        statement.executeUpdate(sql1);
+        statement.executeUpdate(sql2);
+        statement.executeUpdate(sql3);
+        connection.commit();
         return 0;
     }
 
@@ -69,7 +69,11 @@ public class PhoenixDML {
     }
 
     //TODO 删除
-    public Integer delete(){
+    public static Integer delete() throws SQLException {
+        String sql1="delete from SAGA_LOG.test_phoenix_api where mykey = 1";
+        statement.executeUpdate(sql1);
+        connection.commit();
+
         return 0;
     }