|
@@ -1,5 +1,7 @@
|
|
|
package com.citygis.service;
|
|
|
|
|
|
+import java.sql.*;
|
|
|
+
|
|
|
/**
|
|
|
* @Package com.citygis.service
|
|
|
* @Author zyl
|
|
@@ -7,4 +9,21 @@ package com.citygis.service;
|
|
|
* @description: ceshi
|
|
|
*/
|
|
|
public class BigDataService {
|
|
|
+
|
|
|
+ public static void main(String[] args) throws SQLException, ClassNotFoundException {
|
|
|
+ Class.forName("org.apache.hive.jdbc.HiveDriver");
|
|
|
+ String jdbcUrl = "jdbc:hive2://192.168.20.6:10000/default";
|
|
|
+ Connection conn = DriverManager.getConnection(jdbcUrl);
|
|
|
+ PreparedStatement ps = conn.prepareStatement("select * from test");
|
|
|
+ ResultSet rs = ps.executeQuery();
|
|
|
+ int num = rs.getMetaData().getColumnCount();
|
|
|
+ while (rs.next()) {
|
|
|
+ for (int i = 1; i <= num; i++) {
|
|
|
+ System.out.println("column:" + i + rs.getObject(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ rs.close();
|
|
|
+ ps.close();
|
|
|
+ conn.close();
|
|
|
+ }
|
|
|
}
|