I was trying to execute hive ACID transaction properties in Hive 0.14 like insert, delete and update through Java.I am able to set the required ACID transaction properties. Also able to create the table with transaction properties. But it's failing. Below is the sample code :
public class HiveJdbcClient {
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 = DriverManager.getConnection("jdbc:hive2://ipaddress:port/default", "user", "password");
Statement stmt = con.createStatement();
stmt.execute("set set hive.support.concurrency=true");
stmt.execute("set hive.enforce.bucketing=true");
stmt.execute("set hive.exec.dynamic.partition.mode=nonstrict");
stmt.execute("set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DbTxnManager");
stmt.execute("set hive.compactor.initiator.on=true");
stmt.execute("set hive.compactor.worker.threads=2");
String tableName = "hive_acid_test";
stmt.execute("drop table if exists " + tableName);
stmt.execute("create table " + tableName + " (id int, name string,department string) clustered by (department) into 3 buckets stored as orc TBLPROPERTIES ('transactional'='true')");
stmt.execute("insert into table hive_acid_test values(1,'jon','sales')");
}
}
Getting the following exception while trying to insert:
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:296) at promo.hive.sample.HiveJdbcClient.main(HiveJdbcClient.java:49)
The same insert command is working from command line. Please help me find the issue.