Jdbc Hive2无效的Url异常 [英] Jdbc Hive2 Invalid Url Exception

查看:400
本文介绍了Jdbc Hive2无效的Url异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Hortonwork集群(Linux),并希望使用JDBC从远程主机将数据加载到Hive中。
我试图让JDBC连接在群集上首先在群集上工作,这样我才知道我在远程尝试之前做了正确的操作。



Hive已经成功安装,我可以通过直线连接,没有任何问题:

  / usr / lib / hive / bin / beeline 
直线版本0.13.0.2.1.4.0-632由Apache Hive
直线> !connect jdbc:hive2:// localhost:10000
在3ms中完成扫描
连接到jdbc:hive2:// localhost:10000
为jdbc输入用户名:hive2:// localhost:10000 :someuser
为jdbc输入密码:hive2:// localhost:10000:******
连接到:Apache Hive(版本0.13.0.2.1.4.0-632)
驱动程序:Hive JDBC(版本0.13.0.2.1.4.0-632)
事务隔离:TRANSACTION_REPEATABLE_READ

我的java类看起来像:

  public class HiveConn {
private static String driverName =org.apache .hadoop.hive.jdbc.HiveDriver;
public static void main(String [] args)throws SQLException {
HiveConn myJob = new HiveConn();
myJob.execute();
}
public void execute()throws SQLException {
//mLogger.info(\"Start HiveJob);
System.out.println(Start HiveJob);
尝试{
Class.forName(driverName);
} catch(ClassNotFoundException e){
// TODO自动生成的catch块
e.printStackTrace();
System.exit(1);

Connection con = DriverManager.getConnection(jdbc:hive2:// localhost:10000,,);
// Connection con = DriverManager.getConnection(jdbc:hive2:// localhost:10000,root,);
// Statement stmt = con.createStatement();
String sql =SHOW TABLES;
System.out.println(Running:+ sql);
System.out.println(HiveJob executed!);


$ / code $ / pre
$ b $例外

 启动HiveJob 
线程main中的异常java.sql.SQLException:无效的URL:jdbc:hive2:// localhost:10000 / default
at org.apache.hadoop.hive.jdbc.HiveConnection。< init>(HiveConnection.java:86)
at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106 )
在java.sql.DriverManager.getConnection(DriverManager.java:571)
在java.sql.DriverManager.getConnection(DriverManager.java:215)
在HiveConn.execute(HiveConn。 java:29)HiveConn.main上的
(HiveConn.java:17)

我是以root身份登录,因此应该没有权限问题。
我已经尝试了所有可能的Url组合,包括完整的主机名称,例如

  jdbc:hive2://servername.company.com :10000 

,并在每个可能的组合中添加默认和用户名到URL:

jdbc:hive2:// localhost:10000 / defaultuser

我尝试将认证NOSASL添加到hive-site.xml并将其添加到以下URL:

jdbc:hive2://servername.company.com :10000; auth = NoSasl

My ip table config看起来像:

  127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
ip.address servername .company.com
ip.address servername.company.com
ip.address servername.company.com
ip.address servername.company.com

我不知道该如何尝试更多。这可能是我很想念的东西。

解决方案

糟糕了。
我使用的是错误的Drivername,正确的应该是:
$ b $ pre $ private $ static String driverName =org.apache .hive.jdbc.HiveDriver;

怀疑是一个愚蠢的错误...


I have a Hortonwork cluster (Linux) and want to use JDBC for loading data into Hive from a remote host. I am trying to get the JDBC connection to work locally on the cluster first so that I know I have done it correct before trying remotely.

Hive has been succesfully installed and I can connect through beeline without any problems:

/usr/lib/hive/bin/beeline
Beeline version 0.13.0.2.1.4.0-632 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
scan complete in 3ms
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: someuser
Enter password for jdbc:hive2://localhost:10000: ******
Connected to: Apache Hive (version 0.13.0.2.1.4.0-632)
Driver: Hive JDBC (version 0.13.0.2.1.4.0-632)
Transaction isolation: TRANSACTION_REPEATABLE_READ

My java class looks like:

public class HiveConn {
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
HiveConn myJob = new HiveConn();
myJob.execute();
}
public void execute() throws SQLException {
//mLogger.info("Start HiveJob");
System.out.println("Start HiveJob");
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000", "", "");
//Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000", "root", "");
//Statement stmt = con.createStatement();
String sql = "SHOW TABLES";
System.out.println("Running: " + sql);
System.out.println("HiveJob executed!");
}
}

The exception:

Start HiveJob
    Exception in thread "main" java.sql.SQLException: Invalid URL: jdbc:hive2://localhost:10000/default
        at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:86)
        at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:215)
        at HiveConn.execute(HiveConn.java:29)
        at HiveConn.main(HiveConn.java:17)

I am logged in as root so should be no permission issues. I have tried every possible Url combo including full hostname like

 jdbc:hive2://servername.company.com:10000

and also adding "default" and user-name in every possible combo to the URL like:

jdbc:hive2://localhost:10000/default "user"

I have tried to add authentication NOSASL to the hive-site.xml and adding it to the URL like:

 jdbc:hive2://servername.company.com:10000;auth=NoSasl

My ip table config looks like:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
ip.address  servername.company.com
ip.address  servername.company.com
ip.address  servername.company.com
ip.address  servername.company.com

I don't know what to try more. It's probably something silly I am missing.

解决方案

Oops found it. I was using the wrong Drivername and the correct one should be:

private static String driverName = "org.apache.hive.jdbc.HiveDriver";

As suspected a silly mistake...

这篇关于Jdbc Hive2无效的Url异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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