Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.sql.SQLException: No suitable driver found for jdbc:hive://localhost:10000/default

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?

like image 743
Wilianto Indrawan Avatar asked Nov 15 '15 16:11

Wilianto Indrawan


1 Answers

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

like image 154
Wilianto Indrawan Avatar answered Sep 25 '22 02:09

Wilianto Indrawan