通过JDBC连接到Hive时的Java

通过JDBC连接到Hive时的Java

本文介绍了通过JDBC连接到Hive时的Java NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试从Eclipse中的简单Java程序连接到Hive时出现以下错误。它看起来像连接然后抛出这个错误。我可以通过直线连接到Hive Thrift服务器,而不会出现问题。

这两个libthrift .jar文件都是0.9.2。客户端和服务器上相同。以下.jar文件的服务器和客户端版本相同:

  hive-jdbc * .jar 1.2.0 
hive-service * .jar 1.2.0
libfb303-0.9.0.jar 0.9.2
libthrift-0.9.0.jar 0.9.2
log4j-1.2.16.jar 1.2.16
slf4j-api-1.6.1.jar 1.7.5
slf4j-log4j12-1.6.1.jar 1.7.5
commons-logging-1.0.4.jar 1.1。 3


线程main中的异常java.lang.NoSuchMethodError:org.apache.thrift.protocol.TProtocol.getScheme()Ljava / lang / Class;
at org.apache.thift.TServiceClient.sendBase(TServiceClient.java:63)
at org.apache.hive.service.cli.thrift.TCLIService $ OpenSession_args.write(TCLIService.java:1854)

at org.apache.hive.service.cli.thrift.TCLIService $ Client.send_OpenSession(TCLIService.java:150)
at org.apache.hive.service.cli.thrift.TCLIService $ Client。 OpenSession(TCLIService.java:142)
at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:578)
at org.apache.hive.jdbc.HiveConnection。< init> (HiveConnection.java:192)
在org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
在java.sql.DriverManager.getConnection(未知源)
在java.sql.DriverManager.getConnection(未知源)

我使用的libthrift版本列出Apache具有getScheme()方法。



任何帮助将不胜感激! 确保你已经在您的类路径中包含了必需的jar文件。正如你所说的那样在你的当地工作,那么我猜你已经做到了。如果它没有在实际的服务器上工作,那么确保你已经部署了所需的罐子。


I'm getting the following error when attempting to connect to Hive from a simple java program in Eclipse. It looks like it connects then throws this error. I can connect to Hive Thrift server locally through beeline without issues.

both libthrift .jar files are 0.9.2. Same on client and server. Version for server and client for the following .jar files are the same:

hive-jdbc*.jar              1.2.0
hive-service*.jar           1.2.0
libfb303-0.9.0.jar          0.9.2
libthrift-0.9.0.jar         0.9.2
log4j-1.2.16.jar            1.2.16
slf4j-api-1.6.1.jar         1.7.5
slf4j-log4j12-1.6.1.jar     1.7.5
commons-logging-1.0.4.jar   1.1.3


Exception in thread "main" java.lang.NoSuchMethodError: org.apache.thrift.protocol.TProtocol.getScheme()Ljava/lang/Class;
       at org.apache.hive.service.cli.thrift.TCLIService$OpenSession_args.write(TCLIService.java:1854)
       at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63)
       at org.apache.hive.service.cli.thrift.TCLIService$Client.send_OpenSession(TCLIService.java:150)
       at org.apache.hive.service.cli.thrift.TCLIService$Client.OpenSession(TCLIService.java:142)
       at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:578)
       at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:192)
       at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
       at java.sql.DriverManager.getConnection(Unknown Source)
       at java.sql.DriverManager.getConnection(Unknown Source)

The libthrift version I am using is listed by Apache as having the getScheme() method.

Any help would be greatly appreciated!

解决方案

Make sure you have included the required jar files on your classpath. As you said its working on your local then I guess you did. If its not working on the actual server then make sure you have deployed the required jars.

这篇关于通过JDBC连接到Hive时的Java NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 05:26