当前位置: 首页 > 知识库问答 >
问题:

通过配置单元JDBC在Tez上配置单元-错误

穆铭晨
2023-03-14

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

下面2个查询来自Java代码。

  • select*from ascii——运行良好
  • 从ascii选择计数(*)或从ascii选择计数(1)——失败并出现错误

我的代码:

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)

共有3个答案

骆利
2023-03-14

诀窍是使用用户hadoop

张炳
2023-03-14

我还修复了在连接字符串中传递用户名的问题。谢谢:)

鲁光霁
2023-03-14

是的,我已经通过传递下面的连接对象与我的用户名固定谢谢......:)

con = DriverManager.getConnection("jdbc:hive2://localhost:10000/labs", "hdpadmin","");
 类似资料:
  • 我们有配置了FreeIPA的HDP-2.2集群。但当我们试图通过knox访问HiveJDBC时,我们面临着一个问题。以下是我们正在使用的JDBC URI: jdbc: hive2://xxxxxxxxx: 8443/; ssl=true; sslTrustStore=/var/lib/Knox/data/Security/keystore/gateway.jks; Trust StorePassw

  • 我正在遵循doc:http://docs.aws.amazon.com/elasticmapreduce/latest/releaseguide/emr-dev-create-matchore-outside.html并尝试使用AWSCLI==1.10.38创建emr集群。 我使用文档中提到的以下命令: 但是它说“AWS:error:valid json argument for option--

  • 我在java中开发了一个工作正常的配置单元udf,我的函数返回输入与配置单元表中列之间的最佳匹配,因此它有以下简化的伪代码: 我的问题是,如果这个函数是由Hive调用的,为什么我需要在代码中连接到Hive?我可以使用使用我的功能的用户所连接的当前连接吗?

  • 当我运行以下配置单元命令时 hive-e‘选择msg,将(*)从表中计数为cnt,其中像“%abcd%”这样的msg按msg排序按cnt desc;’sed的/[\t]/,/g'>table.csv 失败:ParseException第1:89行无法识别表达式规范中“like”“%”“password”附近的输入 我知道在指定字符串“%abcd%”时有问题。该命令在配置单元环境中工作正常,但这里我

  • 我正在我的ubuntu上运行Hive2,并尝试通过hive接口和Beeline\JDBC创建表。我通过配置单元接口创建表没有问题,但是当通过jdbc访问时,我得到一个权限被拒绝的错误。 从异常中,我看到它试图在一个不存在的目录中创建表(/user/hive/warehouse/...) 那么它为什么要在/user/hive/warehouse下创建metastore_db呢?