我编写了以下Java代码,通过Sqoop将MySql数据导入hive。
import com.cloudera.sqoop.Sqoop;
import com.cloudera.sqoop.SqoopOptions;
import com.cloudera.sqoop.SqoopOptions.IncrementalMode;
import com.cloudera.sqoop.tool.ImportTool;
public class Test_sqlTohdfs {
public static void main(String[] args) {
SqoopOptions options = new SqoopOptions();
options.setConnectString("jdbc:mysql://192.168.0.150:3306/college_mysql");
options.setUsername("root");
options.setPassword("root");
options.setTableName("student");
options.setSplitByCol("rollNo");
options.setHiveDatabaseName("College_hive");
options.setOverwriteHiveTable(true);
options.setHiveTableName("stud_02");
options.setHiveImport(true);
int ret = new ImportTool().run(options);
}
}
我已成功将MySql数据导入Hdfs文件,但是当我尝试使用上面的代码将MySql数据导入hive时,它会出现以下错误,我尝试了很多,但没有得到任何解决方法。请提前帮助我解决它。
[main] ERROR org.apache.sqoop.tool.ImportTool - Encountered IOException running import job: java.io.IOException: Hive exited with status 44
at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:385)
at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:335)
at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:239)
at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:514)
at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605)
at com.test.Test_sqlTohdfs.main(Test_sqlTohdfs.java:25)