복붙노트

[HADOOP] 예외 JDBC를 통해 연결하는 동안 하이브

HADOOP

예외 JDBC를 통해 연결하는 동안 하이브

다음은 JDBC 연결을 사용하여 하이브를 연결하는 동안 내가 직면하고있어 예외입니다.

Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "hive", "");

오류:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.thrift.protocol.TProtocol.getScheme()Ljava/lang/Class;
    at org.apache.hadoop.hive.service.ThriftHive$execute_args.write(ThriftHive.java:1076)
    at org.apache.thrift.TServiceClient.sendBase(TServiceClient.java:63)
    at org.apache.hadoop.hive.service.ThriftHive$Client.send_execute(ThriftHive.java:110)
    at org.apache.hadoop.hive.service.ThriftHive$Client.execute(ThriftHive.java:102)
    at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:187)
    at org.apache.hadoop.hive.jdbc.HiveStatement.execute(HiveStatement.java:127)
    at org.apache.hadoop.hive.jdbc.HiveConnection.configureConnection(HiveConnection.java:126)
    at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:121)
    at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
    at java.sql.DriverManager.getConnection(DriverManager.java:620)
    at java.sql.DriverManager.getConnection(DriverManager.java:200)
    at HiveJdbcClient.main(HiveJdbcClient.java:24)

libthrift-0.9.0.jar의 클래스 TProtocol.java이 방법 getScheme이없는 ().

사람이 제가 사용할 필요가있는 항아리 파일 알려 주시기 바랍니다 수 있습니다.

감사합니다.

해결법

  1. ==============================

    1.아래 코드를 사용해보십시오 ....

    아래 코드를 사용해보십시오 ....

    package com.services.connections;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    
    public class ConnectHive
    {
      public static void main(String[] args) throws SQLException,ClassNotFoundException
     {
        // TODO Auto-generated method stub
        String connectionURL = "jdbc:hive://localhost:9999/javatesting";
        String drivername = "org.apache.hadoop.hive.jdbc.HiveDriver";
        String username = "";
        String password = "";
        try {
            Class.forName(drivername);
                } 
            catch (ClassNotFoundException e)
              {
            // TODO Auto-generated catch block
            e.printStackTrace();
            System.exit(1);
              }
              try {
                Connection con = DriverManager.getConnection(connectionURL, username, password);
                if(con != null) 
                {
                System.out.println("Connected");
                    }
                else
                    {
                System.out.println("Not Connected");
                }
                Statement stmt = con.createStatement(); 
                // select * query
                String sql;
                ResultSet res;
                sql = "select * from javatesting.testdata";
                System.out.println("Running: " + sql);
                    res = stmt.executeQuery(sql);
                while (res.next())
                {
                      System.out.println(String.valueOf(res.getString(1)) + "\t" + res.getString(2));
                }
                  }
              catch(SQLException se) 
              {
                se.printStackTrace();
              }
      }
    
    }
    
  2. from https://stackoverflow.com/questions/19925926/exception-while-connecting-to-hive-through-jdbc by cc-by-sa and MIT license