The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

Hortonworks Sandbox Forum

JDBC connection to Hive Permission issue

  • #53173
    Mykola Ostapchuk
    Participant

    Hi,
    I’m trying to make connection to Hive from a Java client. I’m using the latest Hive jars:

    hadoop-core-0.19.1.jar
    hive-jdbc-0.13.0.2.1.1.0-385.jar
    hive-exec-0.13.0.2.1.1.0-385.jar
    hive-metastore-0.13.0.2.1.1.0-385.jar
    hive-service-0.13.0.2.1.1.0-385.jar
    libthrift-0.9.0.jar
    libfb303-0.9.0.jar

    I’ve made Port forwarding on Sandbox Network – Port Forwarding Rules: hive -> TCP -> 127.0.0.1 -> 2200 -> 10000.

    My Java code:
    __________________________________________
    String driverName = “org.apache.hive.jdbc.HiveDriver”;
    try{
    Class.forName(driverName);
    }catch (ClassNotFoundException e) {
    e.printStackTrace();
    System.exit(1);
    }
    Connection con = DriverManager.getConnection(“jdbc:hive2://127.0.0.1:2200/default”, “hive”, “”);
    Statement stmt = con.createStatement();
    ResultSet res = stmt.executeQuery(“SELECT * FROM mytable”);
    __________________________________________
    The last statement is causing the following exception:

    java.sql.SQLException: Error while compiling statement: FAILED: HiveAccessControlException Permission denied. Principal [name=hive, type=USER] does not have following privileges on Object [type=TABLE_OR_VIEW, name=default.mytable] : [SELECT]
    org.apache.hive.jdbc.Utils.verifySuccess(Utils.java:121)
    org.apache.hive.jdbc.Utils.verifySuccessWithInfo(Utils.java:109)
    …….

    Does anybody know how to fix this?
    Thanks!

  • Author
    Replies
  • #53737
    Dave
    Moderator

    Hi Mykola,

    Can you log into MySQL and check the permissions for hive on this table.
    You may want to grant all for ‘hive’@’%’ as this is being thrown from your local machine by MySQL

    Thanks

    Dave

    #80512
    Eric Escamilla
    Participant

    I know it’s real late, but this issue has been bugging me as well.  Although, you may also have to set the following property to true in hive-site.xml:

    set hive.server2.enable.impersonation to true

The forum ‘Hortonworks Sandbox’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.