我試圖在Hive 0.14中執行配置單元ACID事務屬性,如通過Java插入,刪除和更新。我可以設置所需的ACID事務屬性。還能夠創建具有事務屬性的表。但它失敗了。下面是示例代碼:使用配置單元jdbc連接的Hive ACID事務屬性
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')");
}
}
收到以下異常試圖插入:在處理語句錯誤:失敗:
異常線程「main」 java.sql.SQLException中的執行錯誤,從org.apache.hadoop.hive.ql.exec.mr.MapRedTask返回代碼1 at org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:296) at promo.hive.sample.HiveJdbcClient.main (HiveJdbcClient.java:49)
相同的插入命令正在從命令行工作。請幫我找到問題。
有一個類似的線程在這裏:http://hortonworks.com/community/forums/topic/mapredtask-failed-when-executing-hive-mapreduce-query-from-直線/ – Barett 2015-04-01 19:22:22
此鏈接不會導致解決方案。這裏沒有權限異常。 – Sachin 2015-04-01 20:26:12