我使用Hortonworks Hadoop的HDP-2.3.2.0-2950 蜂巢超過TEZ引擎蜂巢超過TEZ通過蜂巢JDBC - 錯誤
低於2個查詢是從Java代碼。
select * from ascii
- 行之有效select count(*) from ascii or select count(1) from ascii
- 失敗,錯誤出
我的代碼:
package com.hadoop.hive;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
*
* @author hdpadmin
*
*/
public class HiveReadJDBCMain {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
/**
* @param args
* @throws SQLException
*/
public static void main(String[] args) throws SQLException {
Connection con = null;
PreparedStatement pst = null;
ResultSet res = null;
try {
// Load Hive Driver Clazz
Class.forName(driverName);
// No username and password required.(running in a local machine)
con = DriverManager.getConnection("jdbc:hive2://localhost:10000/labs");
//Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000/labs", "<Username>", "<Password>");
String tableName = "ascii";
// select * query
String sql = "select * from " + tableName;
System.out.println("Select Query Running: " + sql);
pst = con.prepareStatement(sql);
res = pst.executeQuery();
while (res.next()) {
System.out.println(String.valueOf(res.getInt(1)) + "\t" + res.getString(2));
}
pst.close();
res.close();
// regular hive query
sql = "select count(*) from " + tableName;
System.out.println("Count Query Running: " + sql);
pst = con.prepareStatement(sql);
res = pst.executeQuery();
while (res.next()) {
System.out.println(res.getString(1));
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
System.exit(1);
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
} finally {
res.close();
pst.close();
con.close();
}
}
}
Error
java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.tez.TezTask
at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:282)
at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:378)
at org.apache.hive.jdbc.HivePreparedStatement.executeQuery(HivePreparedStatement.java:109)
at com.hadoop.hive.HiveReadJDBCMain.main(HiveReadJDBCMain.java:48)
是否添加用戶名修復了您的錯誤?我陷入了同樣的錯誤。如果您找到解決方案,請給我加標籤。是的,我添加了用戶名,但仍然出現錯誤 – Saurab