Required field ‘client_protocol‘ is unset!

spark连接hive报错

Caused by: java.sql.SQLException: Could not establish connection to jdbc:hive2://192.168.xx.101:10000: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{use:database=default})
	at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:588)
	at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:186)
	... 52 more
Caused by: org.apache.thrift.TApplicationException: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{use:database=default})
	at org.apache.thrift.TApplicationException.read(TApplicationException.java:111)
	at org.apache.thrift.TServiceClient.receiveBase(TServiceClient.java:79)
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.recv_OpenSession(TCLIService.java:168)
	at org.apache.hive.service.rpc.thrift.TCLIService$Client.OpenSession(TCLIService.java:155)
	at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:576)
	... 53 more

原因是Hive Jdbc的版本和Hive的版本不同造成的, hive版本1.1.0,jdbc用了2.1.1 ,把jdbc的版本纠正即可

<dependency>
            <groupId>org.apache.hive</groupId>
            <artifactId>hive-jdbc</artifactId>
            <version>1.1.0</version>
</dependency>

总结

  • hive jdbc驱动的版本要和hive的版本相同

你可能感兴趣的:(hive,Hive,hive,jdbc)