无法连接到配置单元server2(sql异常、thrift传输异常等)

k7fdbhmy  于 2021-06-26  发布在  Hive
关注(0)|答案(1)|浏览(653)

我们尝试使用JAR连接到hive server2数据库:
hadoop-common-2.7.1.2.3.2.0-2950.jar
hive-jdbc-1.2.1.2.3.2.0-2950-standalone.jar
我们将这两个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

有人能帮我解决这个问题吗?

odopli94

odopli941#

错误72是错误的url问题。您的hive2服务器是否以http模式运行?
在http模式下运行的hiveserver2的连接url为:-

jdbc:hive2://<host>:<port>/<db>;transportMode=http;httpPath=<http_endpoint>

where:- is 在hive-site.xml中配置的相应http端点。默认值为cliservice。
http传输模式的默认端口是10001。
你能试试下面的网址吗:

jdbc:hive2://10.205.64.70:10001/default;transportMode=http;httpPath=cliservice

相关问题