Jdbc Hive2 Invalid Url Exception

I have a Hortonwork cluster (Linux) and you want to use JDBC to load data into Hive from a remote host. I am trying to start a JDBC connection locally in a cluster so that I know that I did it right before trying remotely.

Hive was successfully installed, and I can connect through beeline without any problems:

/usr/lib/hive/bin/beeline
Beeline version 0.13.0.2.1.4.0-632 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
scan complete in 3ms
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: someuser
Enter password for jdbc:hive2://localhost:10000: ******
Connected to: Apache Hive (version 0.13.0.2.1.4.0-632)
Driver: Hive JDBC (version 0.13.0.2.1.4.0-632)
Transaction isolation: TRANSACTION_REPEATABLE_READ

My java class is as follows:

public class HiveConn {
private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver";
public static void main(String[] args) throws SQLException {
HiveConn myJob = new HiveConn();
myJob.execute();
}
public void execute() throws SQLException {
//mLogger.info("Start HiveJob");
System.out.println("Start HiveJob");
try {
Class.forName(driverName);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.exit(1);
}
Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000", "", "");
//Connection con = DriverManager.getConnection("jdbc:hive2://localhost:10000", "root", "");
//Statement stmt = con.createStatement();
String sql = "SHOW TABLES";
System.out.println("Running: " + sql);
System.out.println("HiveJob executed!");
}
}

An exception:

Start HiveJob
    Exception in thread "main" java.sql.SQLException: Invalid URL: jdbc:hive2://localhost:10000/default
        at org.apache.hadoop.hive.jdbc.HiveConnection.<init>(HiveConnection.java:86)
        at org.apache.hadoop.hive.jdbc.HiveDriver.connect(HiveDriver.java:106)
        at java.sql.DriverManager.getConnection(DriverManager.java:571)
        at java.sql.DriverManager.getConnection(DriverManager.java:215)
        at HiveConn.execute(HiveConn.java:29)
        at HiveConn.main(HiveConn.java:17)

I am logged in as root, so there should be no resolution problems. I tried all possible Url compilations, including the fully qualified host name, e.g.

 jdbc:hive2://servername.company.com:10000

and also adding "default" and user-name in every possible combo to the URL like:

jdbc:hive2://localhost:10000/default "user"

I have tried to add authentication NOSASL to the hive-site.xml and adding it to the URL like:

 jdbc:hive2://servername.company.com:10000;auth=NoSasl

The ip table configuration looks like this:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
ip.address  servername.company.com
ip.address  servername.company.com
ip.address  servername.company.com
ip.address  servername.company.com

I do not know what to try anymore. Maybe something stupid is missing me.

+4
source share
1

. Drivername, :

private static String driverName = "org.apache.hive.jdbc.HiveDriver";

...

+3

All Articles