Da sqoop options-metoden er forældet, kan du bruge følgende kode:
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);
}
Brug venligst den rigtige hadoop og hive lager path
, username
, password
til mysql. Tjek venligst din port fra core-site.xml
(i mit tilfælde er det 54310)