我正在尝试使用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>
我正在使用带有Hive 1.1.0和Hadoop 2.6.0的CDH 5.8.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
和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'
此致
答案 0 :(得分:0)
试试这个罐子:
depencency:
<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>
你可以在这里找到这个罐子:https://search.maven.org
这个罐子在JMeter为我工作。