无法通过JAVA连接到HIVE2
参考Hive2创建了一个连接到HIVE2服务器(非本地)的简单java程序,在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.(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)
这里和这里提到但它没有解决问题。
您使用hive2类型的jdbc url。
正如Hive wiki中所解释的那样,不再推荐使用thrift jdbc:
JDBC
本文档描述了原始Hive Server(有时称为Thrift服务器或HiveServer1)的JDBC客户端。 有关HiveServer2 JDBC客户端的信息,请参阅HiveServer2客户端文档中的JDBC。 建议使用HiveServer2; 最初的HiveServer有几个并发问题,缺少HiveServer2中的几个function。
在hive2 jdbc上查看此信息 。 例如,驱动程序可以在这里找到:
http://mvnrepository.com/artifact/org.apache.hive/hive-jdbc/1.2.1
- Hadoop映射器和reducer输出不匹配
- Hadoop中的CSV处理
- 如何在Hadoop中使用CompressionCodec
- Hadoop:java.lang.ClassCastException:org.apache.hadoop.io.LongWritable无法强制转换为org.apache.hadoop.io.Text
- 在zookeeper中创建路径的最有效方法,路径的根元素可能存在也可能不存在?
- 为什么检查hadoop中是否存在文件会导致NullPointerException?
- 将外部jar设置为hadoop classpath
- Mahout:读取自定义输入文件
- Phoenix不会正确显示负整数值