java.sql.SQLException: 找不到适合 jdbc:hive://localhost:10000/default 的驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33722139/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
提问by Wilianto Indrawan
I'm new with Hadoop and the ecosystem. I'm trying Hive with JDBC in Java. This is my simple code only to test the driver:
我是 Hadoop 和生态系统的新手。我正在尝试使用 Java 中的 JDBC Hive。这是我的简单代码,仅用于测试驱动程序:
import java.sql.DriverManager;
import java.sql.SQLException;
public class PrepareHiveTable {
private static String driverName = "org.apache.hive.jdbc.HiveDriver";
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName(driverName);
Connection con = DriverManager.getConnection("jdbc:hive://localhost:10000/default", "", "");
}
}
I've imported org.apache.hive.jdbc.HiveDriver
to the classpath and this is the driver list on my DriverManager
:
我已经导入org.apache.hive.jdbc.HiveDriver
到类路径,这是我的驱动程序列表DriverManager
:
org.apache.calcite.avatica.remote.Driver@45ff54e6
org.apache.calcite.jdbc.Driver@3581c5f3
org.apache.derby.jdbc.AutoloadedDriver40@4f8e5cde
com.mysql.jdbc.Driver@6f75e721
org.apache.hive.jdbc.HiveDriver@69222c14
But when I run the code I get this error:
但是当我运行代码时,我收到此错误:
Exception in thread "main" java.sql.SQLException: No suitable driver found for
jdbc:hive://localhost:10000/default
at java.sql.DriverManager.getConnection(DriverManager.java:689)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at PrepareHiveTable.main(PrepareHiveTable.java:24)
Java Result: 1
Anyone here know how can it happen? And how to solve it?
这里有人知道怎么会发生吗?以及如何解决?
回答by Wilianto Indrawan
I found the solution. I use hive 1.2.1 so I need to write jdbc:hive2://localhost:10000/default
instead of jdbc:hive://localhost:10000/default
我找到了解决方案。我使用 hive 1.2.1 所以我需要写jdbc:hive2://localhost:10000/default
而不是jdbc:hive://localhost:10000/default
thank you
谢谢
回答by mannedear
I'm using hive-jdbc-1.0.0.jar
and I got the connection established successfully to hive db. I'm also sharing other details which I used here.
我正在使用hive-jdbc-1.0.0.jar
并且已成功建立到 hive db 的连接。我还分享了我在这里使用的其他细节。
Driver Name: org.apache.hive.jdbc.HiveDriver
URL: ("jdbc:hive2://localhost:10000/default","username","password")
驱动程序名称:org.apache.hive.jdbc.HiveDriver
网址:("jdbc:hive2://localhost:10000/default","username","password")
Below are the total jars I used for my project to work on hive db from my java project.
以下是我用于我的项目以处理来自我的 java 项目的 hive db 的总 jars。