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 {
            catch (ClassNotFoundException e) {
          // TODO Auto-generated catch block
        System.exit(1);    }
Connection con_con1 = DriverManager.getConnection("jdbc:hive2://<hostname>:<port>/<db>", "", "");


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: Error getting user info for current user, anonymous
  at org.apache.hive.jdbc.Utils.verifySuccess(
  at org.apache.hive.jdbc.Utils.verifySuccess(
  at org.apache.hive.jdbc.HiveConnection.openSession(
  at org.apache.hive.jdbc.HiveConnection.<init>(
  at org.apache.hive.jdbc.HiveDriver.connect(
  at java.sql.DriverManager.getConnection(
  at java.sql.DriverManager.getConnection(
  at ConnectionTest.main(


Request you help.