[英]java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
I'm new with Hadoop and the ecosystem. 我是Hadoop和生态系统的新手。 I'm trying Hive with JDBC in Java.
我正在用Java中的JDBC尝试Hive。 This is my simple code only to test the driver:
这是我的简单代码,仅用于测试驱动程序:
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?
以及如何解决?
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 谢谢
I'm using hive-jdbc-1.0.0.jar
and I got the connection established successfully to hive db. 我正在使用
hive-jdbc-1.0.0.jar
,我已成功建立连接到hive db。 I'm also sharing other details which I used here. 我也在分享我在这里使用的其他细节。
Driver Name: org.apache.hive.jdbc.HiveDriver
驱动程序名称:
org.apache.hive.jdbc.HiveDriver
URL: ("jdbc:hive2://localhost:10000/default","username","password")
URL :(
("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数据库的总罐子。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.