Home > other >  The Java connection hive use ha and JDBC driver
The Java connection hive use ha and JDBC driver

Time:10-07

Error: Could not establish the connection to the JDBC: hive2://localhost: 10000/metastore: Required field 'client_protocol is unset. Struct: TOpenSessionReq (client_protocol: null, configuration: {use: database=metastore}) (state=08 s01, code=0)
Reason: local jar version is higher than the server

Through Java code, JDBC connection hiveserver2, as follows:
The Connection conn=null;
Try {
Class.forname (" org. Apache. Hive. JDBC. HiveDriver ");
Conn=DriverManager. GetConnection (jdbcUrl, userName, passWord);
} the catch (Exception e) {
e.printStackTrace();
}
Return the conn.

The JDBC connection string 1 is: JDBC: hive2://t - bj - 000/HPC - 02:10 default can connect success;
2 for the JDBC connection string: JDBC: hive2://t - bj - 81, HPC - 02:21 bj - HPC - 01:21 t - 81, t - bj - 81/HPC - 03:21; ServiceDiscoveryMode=zooKeeper; ZooKeeperNamespace=hiveserver2
Unable to connect successfully,
Among them, the connection string 2, through the beeline command can be connected successfully, but by the above code is unable to connect successfully,
I only know that the following list is to use a Zookeeper realized HiveServer2 HA function (ZooKeeperService Discovery), the Client end can be connected HiveServer2 by specifying a nameSpace, rather than a specific host and port,
2, the problem is that the connection string can be connected by a command beeline success, but through the code above is unable to connect successfully, error:
Java. Lang. NullPointerException at org. Apache. Thrift. Transport. TSocket. Open (TSocket. Java: 170) at org. Apache. Thrift. Transport. TSaslTransport. Open (TSaslTransport. Java: 266) at org. Apache. Thrift. Transport. TSaslClientTransport. Open (TSaslClientTransport. Java: 37) at org. Apache. Hive. JDBC. HiveConnection. OpenTransport (HiveConnection. Java: 204) at org. Apache. Hive. JDBC. HiveConnection. & lt; init> (HiveConnection. Java: 176) at org. Apache. Hive. JDBC. HiveDriver. Connect (HiveDriver. Java: 105) at Java. SQL. The DriverManager. GetConnection (DriverManager. Java: 664) at Java. SQL. The DriverManager. GetConnection (DriverManager. Java: 247) at cn. Teld. BDP. Oozie. GetConnection. GetConn (getConnection. Java: 13) at cn. Teld. BDP. Oozie. GetConnection. The main solutions (getConnection. Java: 27), how to use the connection string 2, the connection is successful? Because I use ambari hive1.2 installed, have the hiveserver2Interactive hive2.1 version at the same time, for some reason, I have to use hive2.1 version, but I can't find hive2.1 version of the "JDBC: hive2://t - bj - 000/HPC - 02:10 default" the connection string format,

Reason: the jar package low local version

7. Solution: using CDH jar. Org. Apache. Hive: hive - JDBC: 1.1.0 - cdh5.16.2

CodePudding user response:

Lz, rule of thumb, help me a lot,
  • Related