java 执行 hive sql
时间:2021-07-01 10:21:17
帮助过:4人阅读
select * from t_pub_uid limit 10";
List<String> command =
new ArrayList<String>
();
command.add("hive");
command.add("-e");
command.add(sql);
List<String> results =
new ArrayList<String>
();
ProcessBuilder hiveProcessBuilder =
new ProcessBuilder(command);
Process hiveProcess =
hiveProcessBuilder.start();
BufferedReader br =
new BufferedReader(
new InputStreamReader(hiveProcess.getInputStream()));
String data =
null;
while ((data = br.readLine()) !=
null) {
results.add(data);
}
System.out.println(results.toString());
java 执行 hive sql
标签: