配置单元jdbc错误:java.lang.nosuchfielderror:配置单元\ cli \服务\协议\ v7

9vw9lbht  于 2021-06-28  发布在  Hive
关注(0)|答案(1)|浏览(445)

我正在尝试使用hive2连接器通过jdbc创建到impala的连接。但我得到了一个错误:

Exception in thread "main" java.lang.NoSuchFieldError: HIVE_CLI_SERVICE_PROTOCOL_V7
      at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:175)
      at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
      at java.sql.DriverManager.getConnection(DriverManager.java:664)
      at java.sql.DriverManager.getConnection(DriverManager.java:208)
      at dsnoc.dsnoc_api.dolar.getDolarFromImpala(dolar.java:145)
      at dsnoc.dsnoc_api.dsnoc.main(dsnoc.java:75)

我不知道这是否是一个依赖兼容性问题:

<dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-exec</artifactId>
      <version>1.1.0</version>
  </dependency>
  <dependency>
      <groupId>org.apache.hive</groupId>
      <artifactId>hive-jdbc</artifactId>
      <version>1.1.0</version>
  </dependency>
  <dependency>
      <groupId>org.apache.hadoop</groupId>
      <artifactId>hadoop-common</artifactId>
      <version>2.6.0</version>
  </dependency>

我将cdh5.8.0与hive1.1.0和hadoop2.6.0结合使用
或者可能是代码问题:

public static double getDolarFromImpala(String date)  {
    double dolar = 0.0;
    try {
        Class.forName(JDBC_DRIVER_HIVE);
        String sql = "SELECT valor FROM dolar where fecha ='"+date+"'";

        Connection con = DriverManager.getConnection(JDBC_HIVE2_URL,USERNAME,PASSWORD);
        Statement stmt = con.createStatement();
        ResultSet rs = stmt.executeQuery(sql);

        while(rs.next()){
            dolar = rs.getDouble("valor");                                          
        }
        stmt.close();
        con.close();
    }
    catch(SQLException se){
          //Handle errors for JDBC
          se.printStackTrace();
    }
    catch(Exception e){
          //Handle errors for Class.forName
          e.printStackTrace();
    }
    return dolar;
}

但我认为不是,因为我尝试了一个 Impala jdbc和工作。
另一件事是我没有使用impalajdbc,因为它不读取或发送 USERNAME 以及 PASSWORD ,向我抛出此错误:

[Simba][ImpalaJDBCDriver](500051) ERROR processing query/statement. Error Code: 0, SQL state: TStatus(statusCode:ERROR_STATUS, sqlState:HY000, errorMessage:AuthorizationException: User '' does not have privileges to execute 'SELECT'

当做,

cuxqih21

cuxqih211#

试试这个jar:
hive-jdbc-2.1.1-standalone.jar
hadoop-common-2.7.3.jar
依赖性:

<dependency>
    <groupId>org.apache.hive</groupId>
    <artifactId>hive-jdbc</artifactId>
    <version>2.1.1</version>
</dependency>
<dependency>
    <groupId>org.apache.hadoop</groupId>
    <artifactId>hadoop-common</artifactId>
    <version>2.7.3</version>
</dependency>

你可以在这里找到这个jar:https://search.maven.org
这个jar在jmeter为我工作。

相关问题