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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With