1. 程式人生 > >jdbc連線hive的問題

jdbc連線hive的問題

利用hive jdbc連線hive出現如下問題:

org.apache.hive.jdbc.HiveDriverorg.apache.hive.jdbc.HiveDriverhive_driver:

org.apache.hive.jdbc.HiveDriverhive_url:jdbc:hive2://10.174.242.28:10000/defaultget

connection sessucess獲取hive連線成功!

java.sql.SQLException: Error whileprocessing statement: FAILED: Execution Error, return code 1 fromorg.apache.hadoop.hive.ql.exec.mr.MapRedTask

I tried to use the sql execute in hive andit works well. Then I saw the log in/var/log/hive/hadoop-cmf-hive-HIVESERVER2-cloud000.log.out then I found thereason of this error. The following error:

Job Submission failed with exception'org.apache.hadoop.security.AccessControlException(Permission denied:user=anonymous, access=WRITE,inode="/user":hdfs:supergroup:drwxr-xr-x

Solution

sudo -u hdfs hadoop fs -chmod -R 777  /

This solved the error!

hive_driver:org.apache.hive.jdbc.HiveDriver

hive_url:jdbc:hive2://cloud000:10000/default

get connection sessucess

獲取hive連線成功!

Heart beat

執行insert成功!

或者在con = DriverManager.getConnection(url, user, password);中的user傳進可以操作hive的使用者名稱即可