【问题标题】:Hive over Tez via Hive JDBC - Error通过 Hive JDBC 在 Tez 上进行 Hive - 错误
【发布时间】:2015-10-31 12:28:25
【问题描述】:

我正在使用 Hortonworks Hadoop HDP-2.3.2.0-2950 Hive over Tez 引擎

以下 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)

【问题讨论】:

    标签: hadoop hive hortonworks-data-platform


    【解决方案1】:

    是的,我已通过使用我的用户名传递以下连接对象来修复 谢谢.... :)

    con = DriverManager.getConnection("jdbc:hive2://localhost:10000/labs", "hdpadmin","");
    

    【讨论】:

    • 添加用户名是否解决了您的错误?我遇到了同样的错误。如果您找到解决方案,请标记我。是的,我添加了用户名,但仍然出现错误
    【解决方案2】:

    我还通过在连接字符串中传递用户名来修复。谢谢:)

    【讨论】:

      【解决方案3】:

      如果您使用 AWS Hive JDBC 与默认 EMR 集群通信,Intellij 中的以下设置对我有用

      诀窍是使用用户hadoop

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-04-09
        • 2018-01-21
        • 2016-03-12
        • 1970-01-01
        • 2016-12-08
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多