java.sql.SQLException: hive 中的 org.apache.thrift.transport.TTransportException? [英] java.sql.SQLException: org.apache.thrift.transport.TTransportException in hive?

查看:122
本文介绍了java.sql.SQLException: hive 中的 org.apache.thrift.transport.TTransportException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 java 在 hive 中创建表.我发现

I'm trying to create table in hive with java. I found

java.sql.SQLException: org.apache.thrift.transport.TTransportException

在执行我的代码时.

这是我的代码

public void createTable(String tableName) {
        try{
            Statement stat = con.createStatement();

        String QueryString = "CREATE TABLE '"+tableName+"'(User_Id INTEGER NOT NULL AUTO_INCREMENT, " + "User_Name VARCHAR(25), UserId VARCHAR(20), User_Pwd VARCHAR(15), primary key(User_Id))";

        a = stat.executeUpdate(QueryString);
        if(a==1){
            System.out.println(a);
            System.out.println("Table has been created");
        }

        }catch(Exception e){
        System.out.println(e);}
} 

为什么会抛出这个异常,我该如何解决.?

Why this exception is thrown and how can i fix it.?

推荐答案

这是一条非常通用的错误消息,描述了 hiveserver 出现问题并建议您查看 Hive 日志.如果您访问 hive 日志并找到异常调用堆栈,则可以找到根本原因,或者如果您共享异常,我也许可以帮助您.

It is a very generic error message describing that the hiveserver is having a problem and suggesting you to take a look at the Hive logs. If you access the hive logs and find the exception call stack, you can find the root cause or if you share the exception, I might be able to help you.

我见过的最常见的问题是:

Most common problems I have seen as:

  1. 与并发相关的元存储问题

  1. Issues with meta store related with concurrency

当您以 $hive --service yourhiveserver 的身份启动 hive 服务器并使其运行数天然后运行您的代码时,您的连接可能是代理到服务器的,您将得到完全相同的错误.如果您重新连接到服务器,则此错误将消失.这只是因为一段时间后 wait_time 到期并发生断开连接.

When you start hive server as $hive --service yourhiveserver and keep it running for days and then run your code, it is possible that your connection is broker to server and you will get exact same error. If you reconnect to server and this error will go away. This is only because after some time wait_time expired and disconnect happen.

特定于端口的错误

在启动 Hive 服务器之前,请务必为您的 Hive 服务器设置一个开放端口并设置如下:

Be sure to setup an open Port for your Hive Server and set it as below before starting hive server:

 $export HIVE_PORT=10000
 $hive --service hiveserver
 $ _run_your_code

可能还有其他原因,但是您最好的选择是检查 hive 日志中的调用堆栈以找出根本原因并解决问题.

There could be other reasons, however your best option is to check the call stack in hive logs to root cause and solve the problem.

这篇关于java.sql.SQLException: hive 中的 org.apache.thrift.transport.TTransportException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆