我们尝试使用JAR连接到hive server2数据库:
我们将这两个jar集成到Eclipse项目中,连接到hive数据库的代码是:
Connection con=null;
try {
Class.forName("org.apache.hive.jdbc.HiveDriver");
StringBuffer jdbcConnectionString = new StringBuffer();
jdbcConnectionString.append("jdbc:hive2://10.205.64.70:10000/default");
con = DriverManager.getConnection(jdbcConnectionString.toString(),"********","********");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
但是当我们执行时,我们得到如下错误
java.sql.SQLException: Could not open client transport with JDBC Uri: jdbc:hive2://10.205.64.70:10002/imsone: Invalid status 72
Could not open client transport with JDBC Uri: jdbc:hive2://10.205.64.70:10002/imsone: Invalid status 72
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:209)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:107)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at dummy.connectToHive.connect(connectToHive.java:40)
at dummy.connectToHive.main(connectToHive.java:16)
Caused by: org.apache.thrift.transport.TTransportException: Invalid status 72
at org.apache.thrift.transport.TSaslTransport.sendAndThrowMessage(TSaslTransport.java:232)
at org.apache.thrift.transport.TSaslTransport.receiveSaslMessage(TSaslTransport.java:184)
at org.apache.thrift.transport.TSaslTransport.open(TSaslTransport.java:307)
at org.apache.thrift.transport.TSaslClientTransport.open(TSaslClientTransport.java:37)
at org.apache.hive.jdbc.HiveConnection.openTransport(HiveConnection.java:227)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:182)
... 5 more
有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
错误72是一个糟糕的网址问题。您的hive2服务器是否以HTTP模式运行?
HiveServer2在HTTP模式下运行时的连接URL是: -
jdbc:hive2://<host>:<port>/<db>;transportMode=http;httpPath=<http_endpoint>
其中: - 是hive-site.xml中配置的相应HTTP端点。默认值为cliservice。
HTTP传输模式的默认端口是10001。
你可以尝试下面的网址:
jdbc:hive2://10.205.64.70:10001/default;transportMode=http;httpPath=cliservice