本文介绍了Hive JDBC getConnection 不返回的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注 hive JDBC 教程.我无法让它工作.当它尝试获得连接时,它只是挂起.它也不报告任何错误.我确定 Hive 服务器正在运行.有什么帮助吗?

I'm following the hive JDBC tutorial. I could not get it working. When it try to get the connection it just hangs. It does not report any error either. I'm sure the Hive server is running. Any help?

public class HiveJdbcClient {
  private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
  public static void main(String[] args){
      try {
      Class.forName(driverName);
    } catch (ClassNotFoundException e) {
           e.printStackTrace();
      System.exit(1);
    }

    try{
        Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
        System.out.println("got the connection");

    }catch(SQLException e){
        e.printStackTrace();
    }
  }
}

netstat 的输出:

output of the netstat:

$ sudo netstat -anlp | grep 10000
Password:
tcp        0      0 0.0.0.0:10000               0.0.0.0:*                   LISTEN      27738/java
tcp      107      0 127.0.0.1:10000             127.0.0.1:45910             ESTABLISHED 27738/java
tcp        0      0 127.0.0.1:33665             127.0.0.1:10000             ESTABLISHED 24475/java
tcp        0      0 127.0.0.1:45910             127.0.0.1:10000             ESTABLISHED 7445/java
tcp      107      0 127.0.0.1:10000             127.0.0.1:33665             ESTABLISHED 27738/java

推荐答案

Naresh: 尝试停止 triffserver,然后从终端移动到 HIVE_HOME/bin 目录,然后使用以下命令启动 hive trift 服务器./hive --service hiveserver 10000 & 命令.然后尝试运行该程序.按照 hive 客户端 wiki 示例创建一个表.然后在下一步中执行 show tables 查询.执行此步骤后,请告诉我们结果.之后我们可以进行讨论.

Naresh: Try stopping the triffserver, then move to the HIVE_HOME/bin directory from your terminal, then start the hive trift server using the ./hive --service hiveserver 10000 & command. Then try running the program. Do a create table as per the hive client wiki example . Then do a show tables query in the next step. Let us know the result once this steps are followed. We can have a discussion after that.

这篇关于Hive JDBC getConnection 不返回的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:12