java.sql.SQLException:找不到适合jdbc的驱动程序:hive:// localhost:10000 / default [英] java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default
问题描述
我是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,,);
$ / code>
我导入了 org .apache.hive.jdbc.HiveDriver
添加到classpath,这是我的 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
但是当我运行代码时,我得到这个错误:
线程main中的异常java.sql.SQLException:找不到适用于
的驱动程序jdbc:hive:// localhost:10000 / default
在java.sql.DriverManager.getConnection(DriverManager.java:689)
在java.sql.DriverManager.getConnection(DriverManager.java:247)
在PrepareHiveTable.main(PrepareHiveTable.java:24)
Java结果:1
这里的任何人都知道它会如何发生?以及如何解决它?
我找到了解决方案。我使用配置单元1.2.1,所以我需要写 jdbc:hive2:// localhost:10000 / default
而不是 jdbc:hive:// localhost :10000 /默认
谢谢
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:
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.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
thank you
这篇关于java.sql.SQLException:找不到适合jdbc的驱动程序:hive:// localhost:10000 / default的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!