Karena metode opsi sqoop sudah tidak digunakan lagi, Anda dapat menggunakan kode berikut:
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);
}
Harap gunakan path
gudang hadoop dan sarang sarang yang tepat , username
, password
untuk mysql. Silakan periksa port Anda dari core-site.xml
(dalam kasus saya ini adalah 54310)