无法通过JDBC连接到HIVE数据库(使用kerberos)

时间:2019-04-11 18:29:49

标签: jdbc hive kerberos

我正在尝试通过JDBC从我的应用程序访问HIVE数据库。我在连接时遇到问题。

public class HiveJDBC {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";

  /**
 * @param args
 * @throws SQLException
   */
  public static void main(String[] args) throws SQLException {
      try {
      Class.forName(driverName);
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      System.exit(1);
    }
    System.setProperty("java.security.auth.login.config","gss-jaas.conf");
   //System.setProperty("sun.security.jgss.debug","true");     
   //System.setProperty("javax.security.auth.useSubjectCredsOnly",
   //"false");
    System.setProperty("java.security.krb5.conf","krb5.conf");

    Connection con = DriverManager.getConnection("jdbc:hive2://ip-12-***-156-227.ec2.internal:2999,ip-10-***-123-123.ec2.internal:1299,ip-10-230-137-16.ec2.internal:1299/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-llap0;principal=123@ABC.COM");
    Statement stmt = con.createStatement();

命令:

  GC1MS94NXH3QKE:hiveserver2-jdbc-kerberos sathishbalu$ mvn clean install
  GC1MS94NXH3QKE:hiveserver2-jdbc-kerberos sathishbalu$ java  -cp $HADOOP_CLASSPATH:target/hiveserver2-jdbc-1.0-jar-with-dependencies.jar  com.test.HiveJDBC

输出:

19/04/11 13:50:21 WARN conf.HiveConf: hive-site.xml not found on CLASSPATH
19/04/11 13:50:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
19/04/11 13:50:22 INFO service.AbstractService: Service:OperationManager is inited.
19/04/11 13:50:22 INFO service.AbstractService: Service:SessionManager is inited.
19/04/11 13:50:22 INFO service.AbstractService: Service:CLIService is inited.
19/04/11 13:50:22 INFO service.AbstractService: Service:OperationManager is started.
19/04/11 13:50:22 INFO service.AbstractService: Service:SessionManager is started.
19/04/11 13:50:22 INFO service.AbstractService: Service:CLIService is started.
19/04/11 13:50:22 INFO metastore.HiveMetaStore: 0: Opening raw store with implemenation class:org.apache.hadoop.hive.metastore.ObjectStore
19/04/11 13:50:22 INFO metastore.ObjectStore: ObjectStore, initialize called
Exception in thread "main" org.apache.hive.service.ServiceException: Unable to connect to MetaStore!
at org.apache.hive.service.cli.CLIService.start(CLIService.java:86)
at org.apache.hive.service.cli.thrift.EmbeddedThriftCLIService.<init>(EmbeddedThriftCLIService.java:35)
at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:86)
at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:104)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.test.HiveJDBC.main(HiveJDBC.java:29)
Caused by: javax.jdo.JDOFatalInternalException: Unexpected exception caught.

我在这里想念什么?我花了很多时间尝试进行故障排除,但是没有运气。任何帮助表示赞赏。预先感谢

0 个答案:

没有答案