gpt4 book ai didi

Jdbc Hive2 无效 URL 异常

转载 作者:行者123 更新时间:2023-12-02 05:58:53 26 4
gpt4 key购买 nike

我有一个 Hortonwork 集群 (Linux),想要使用 JDBC 将数据从远程主机加载到 Hive 中。我试图首先让 JDBC 连接在集群上本地工作,以便我知道在远程尝试之前我已经完成了正确的操作。

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

/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

我的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");
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!");
}
}

异常(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)

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

 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

我的 ip 表配置如下:

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

我不知道还要尝试什么。这可能是我错过的一些愚蠢的事情。

最佳答案

哎呀找到了。我使用了错误的驱动程序名称,正确的驱动程序名称应该是:

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

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

关于Jdbc Hive2 无效 URL 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55990679/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com