ソースを参照

数据服务代码提交

kouchengxing 4 年 前
コミット
d707ad60d2

+ 50 - 0
dgtis-modules/dgtis-modules-data/src/main/java/com/dgtis/data/test/TestInceptor.java

@@ -0,0 +1,50 @@
+package com.dgtis.data.test;
+
+import com.dgtis.common.core.utils.DateUtils;
+
+import java.sql.*;
+
+/**
+ * @author koucx
+ * @version 1.0
+ * @descption: TODO
+ * @company 神州数码通用软件(洛阳)有限公司
+ * @copyright (c) 2019 LuoYang DGT Co'Ltd Inc. All rights reserved.
+ * @date 2021-01-20
+ * @since JDK1.8
+ */
+public class TestInceptor {
+
+    //Hive2 Driver class name
+    private static String driverName = "org.apache.hive.jdbc.HiveDriver";
+
+    public static void main(String[] args) throws SQLException {
+        try {
+            Class.forName(driverName);
+        } catch (ClassNotFoundException e) {
+            e.printStackTrace();
+            System.exit(1);
+        }
+
+        //Hive2 JDBC URL with LDAP
+        String jdbcURL = "jdbc:hive2://10.32.2.230:10000/shanglifeecif";
+
+        Connection conn = DriverManager.getConnection(jdbcURL);
+        Statement  stmt = conn.createStatement();
+        System.out.println(DateUtils.getTime());
+        ResultSet rs = stmt.executeQuery("select * from InsuranceArrangement where IAID = '1'");
+        System.out.println(DateUtils.getTime());
+        ResultSetMetaData rsmd = rs.getMetaData();
+        int size = rsmd.getColumnCount();
+        while(rs.next()) {
+            StringBuffer value = new StringBuffer();
+            for(int i = 0; i < size; i++) {
+                value.append(rs.getString(i+1)).append("\t");
+            }
+            System.out.println(value.toString());
+        }
+        rs.close();
+        stmt.close();
+        conn.close();
+    }
+}