AnsweredAssumed Answered

Hive JDBC driver error.

Question asked by kumar on Mar 20, 2014
Folks,

We are getting following error while running simple Hive query via JDBC client. But some other queries are working we are using Hive 0.11 with MapR client.


Exception in thread "main" java.sql.SQLException: Query returned non-zero code: 2, cause: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.MapRedTask
at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:194)
at HiveJdbcClient.main(HiveJdbcClient.java:19)


----------



public class HiveJdbcClient {


private static String driverName = "org.apache.hadoop.hive.jdbc.HiveDriver"; 
/** * @param args * @throws SQLException   */
public static void main(String[] args) throws SQLException
{      try {      Class.forName(driverName);    }

catch (ClassNotFoundException e) {          e.printStackTrace();      System.exit(1);    } 
    DriverManager.setLoginTimeout(10000000); // stats is non-blocking
  Connection con = DriverManager.getConnection("jdbc:hive://url:10000/default", "", "");  
  Statement stmt = con.createStatement();    String tableName = "testHiveDriverTable";   
   
  String sql = "select count(1) from " + tableName;   
  System.out.println("Running: " + sql);  
  ResultSet res = stmt.executeQuery(sql);  
  while (res.next())
  {      System.out.println(res.getInt(1));  
  } 
   
}
}

Outcomes