import java.sql.*;
public class HiveJdbcClientApp {
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);
}
Connection con = DriverManager.getConnection("jdbc:hive2://192.168.1.102:14000/default", "hadoop", "");
Statement stmt = con.createStatement();
String sql = "select * from auto_hive_dept_nums";
ResultSet res = stmt.executeQuery(sql);
while (res.next()) {
System.out.println(res.getString(1)+" "+res.getString(2));
}
}
}