0

I written a Java code to access Apache Hive tables.

import java.sql.*;

public class HiveQL {

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

    public static void main(String[] args) throws SQLException
    {
        try{
        Class.forName(drivername);
        }catch(ClassNotFoundException e)
        {
            e.printStackTrace();
            System.exit(1);
        }
        Connection con = DriverManager.getConnection("jdbc:hive2://xxx.xxx.xxx.xxx:10000/db", "", "");

        Statement stmt = con.createStatement();

        ResultSet res = stmt.executeQuery("select distinct ClientName from leadgen_main");

        System.out.println("Output");

        while(res.next())
        {
            System.out.println(res.getString(1));
        }
        con.close();
    }
}

For the above program I am getting the following error:

log4j:WARN No appenders could be found for logger (org.apache.hive.jdbc.Utils).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" java.sql.SQLException: Error while processing statement: FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
    at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:279)
    at org.apache.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:375)
    at com.dwi.java.hive.HiveQL.main(HiveQL.java:22)

For normal queries which are not required mapreduce, are working fine, But when i used this type queries, which perform mapreduce tasks, i am getting the above error.

Please help on this.

Sachin Janani
  • 1,310
  • 1
  • 17
  • 33

0 Answers0