【发布时间】:2015-04-01 19:04:52
【问题描述】:
我试图在 Hive 0.14 中执行 hive ACID 事务属性,例如通过 Java 插入、删除和更新。我能够设置所需的 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 中的异常:处理语句时出错:FAILED:执行错误,从 org.apache.hadoop.hive.ql.exec.mr.MapRedTask 返回代码 1 在 org.apache.hive.jdbc.HiveStatement.execute(HiveStatement.java:296) 在 promo.hive.sample.HiveJdbcClient.main(HiveJdbcClient.java:49)
相同的插入命令正在命令行中工作。请帮我找出问题。
【问题讨论】:
-
这里有一个类似的帖子:hortonworks.com/community/forums/topic/…
-
此链接无法找到解决方案。这里没有权限异常。
标签: java hadoop jdbc hive hortonworks-data-platform