AnsweredAssumed Answered

Getting Error while connecting to Hive via jdbc

Question asked by sunnysingh on Apr 28, 2016
Latest reply on Jul 15, 2016 by maprcommunity

Hi All,

 

After hive upgrade to 1.2, I am unable to connect to Hive via jdbc code. Was using hive server 1 earlier and now have switched to hiveserver2. Below is my simple code.

 

public class ConnectionTest {
      private static String driverName = "org.apache.hive.jdbc.HiveDriver";

public static void main(String[] args) throws SQLException {
   try {
          Class.forName(driverName);
         }
            catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        System.exit(1);    }
Connection con_con1 = DriverManager.getConnection("jdbc:hive2://<hostname>:<port>/<db>", "", "");
System.out.println("Connected");

 

As compared to earlier code have changed the driver name and connection string from hive to hive2. Below is the error I am getting:

 

Exception in thread "main" org.apache.hive.service.cli.HiveSQLException: Failed to open new session: java.lang.RuntimeException: java.lang.RuntimeException: java.io.IOException: Error getting user info for current user, anonymous
  at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:257)
  at org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:248)
  at org.apache.hive.jdbc.HiveConnection.openSession(HiveConnection.java:590)
  at org.apache.hive.jdbc.HiveConnection.<init>(HiveConnection.java:193)
  at org.apache.hive.jdbc.HiveDriver.connect(HiveDriver.java:105)
  at java.sql.DriverManager.getConnection(DriverManager.java:571)
  at java.sql.DriverManager.getConnection(DriverManager.java:215)
  at ConnectionTest.main(ConnectionTest.java:29)

 

Request you help.

 

Thanks,

Sunnysingh

Outcomes