我正在尝试使用 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>
我将 CDH 5.8.0 与 Hive 1.1.0 和 Hadoop 2.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 进行了尝试并成功了。
另一件事是我没有使用 Impala-JDBC,因为它不读取或发送USERNAME
and 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'
问候,