无法通过 JAVA 连接到 HIVE2

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34540948/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-02 23:00:51  来源:igfitidea点击:

Unable to connect to HIVE2 via JAVA

javahadoopjdbchivehiveql

提问by Vinod

enter image description hereReferring to Hive2created a simple java program to connect to HIVE2 server (not local) have added all mentioned jars in the above link in the class path in eclipse as well however when I run the code it throws an error as:

在此处输入图片说明参考Hive2创建了一个简单的 java 程序来连接到 HIVE2 服务器(不是本地)已经在 eclipse 的类路径中的上述链接中添加了所有提到的 jar 但是当我运行代码时,它会抛出一个错误:

09:42:35,580  INFO Utils:285 - Supplied authorities: hdstg-c01-edge-03:20000
09:42:35,583  INFO Utils:372 - Resolved authority: hdstg-c01-edge-03:20000
09:42:35,656  INFO HiveConnection:189 - Will try to open client transport with JDBC Uri: jdbc:hive2://hdstg-c01-edge-03:20000
FAILED: f
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:456)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:178)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
at java.sql.DriverManager.getConnection(DriverManager.java:579)
at java.sql.DriverManager.getConnection(DriverManager.java:221)
at testScripts.HiveJdbcClient.f(HiveJdbcClient.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:85)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:648)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:834)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1142)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:124)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:108)
at org.testng.TestRunner.privateRun(TestRunner.java:771)
at org.testng.TestRunner.run(TestRunner.java:621)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:357)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:352)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:310)
at org.testng.SuiteRunner.run(SuiteRunner.java:259)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1176)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1101)
at org.testng.TestNG.run(TestNG.java:1009)
at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)

Referred hereand herebut it did not resolve the problem.

参考herehere,但没有解决问题。

采纳答案by Jan

You use a hive2 type jdbc url.

您使用 hive2 类型的 jdbc url。

As explained in Hive wiki, the thrift jdbc is no longer recommended:

正如Hive wiki 中所述,不再推荐使用 thrift jdbc:

JDBC

This document describes the JDBC client for the original Hive Server (sometimes called Thrift server or HiveServer1). For information about the HiveServer2 JDBC client, see JDBC in the HiveServer2 Clients document. HiveServer2 use is recommended; the original HiveServer has several concurrency issues and lacks several features available in HiveServer2.

JDBC

本文档描述了原始 Hive 服务器(有时称为 Thrift 服务器或 HiveServer1)的 JDBC 客户端。有关 HiveServer2 JDBC 客户端的信息,请参阅 HiveServer2 客户端文档中的 JDBC。推荐使用 HiveServer2;原始的 HiveServer 有几个并发问题,并且缺少 HiveServer2 中可用的几个功能。

Checkout this infoon hive2 jdbc. Driver can be found here for instance:

在 hive2 jdbc 上查看此信息。例如,可以在此处找到驱动程序:

http://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/1.2.1

http://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/1.2.1