Aangezien de methode sqoop options is verouderd, kunt u de volgende code gebruiken:
public static void importToHive() throws Exception{
Configuration config = new Configuration();
config.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
config.addResource(new Path("/usr/local/hadoop/conf/hdfs-site.xml"));
String[] cmd ={"import", "--connect",<connectionString>,"--username", userName,
"--password", password,"--hadoop-home", "/usr/local/hadoop","--table",<tableName>, "--hive-import","--create-hive-table", "--hive-table",<tableName>,"-target-dir",
"hdfs://localhost:54310/user/hive/warehouse","-m", "1","--delete-target-dir"};
Sqoop.runTool(cmd,config);
}
Gebruik het juiste hadoop en hive magazijn path
, username
, password
voor mysql. Controleer uw poort van core-site.xml
(in mijn geval is het 54310)