我正在使用Sqoop使用UpdateOnly选项更新oracle中的表。
尝试过各种站点上提到的许多建议,但仍然无法正常工作。

代码如下。

    SqoopOptions sqoopClient = new SqoopOptions();

    sqoopClient.setFieldsTerminatedBy(fieldDelim);
    sqoopClient.setLinesTerminatedBy(lineTerminator);
    sqoopClient.setTableName(tableName);

    sqoopClient.setColumns(columnArray);
    //columnArray contains the list of columns to update including the update
    sqoopClient.setUpdateKeyCol("id");

    sqoopClient.setUpdateMode(SqoopOptions.UpdateMode.UpdateOnly);

    sqoopClient.setExportDir(inputDirForExportJob); // gets input from this directory in the HDFS
    sqoopClient.setFileLayout(com.cloudera.sqoop.SqoopOptions.FileLayout.TextFile);

    com.cloudera.sqoop.tool.SqoopTool sqoop_tool = com.cloudera.sqoop.tool.SqoopTool.getTool("export");

    org.apache.sqoop.Sqoop sqoop_export = new org.apache.sqoop.Sqoop(sqoop_tool, hadoop_config, sqoopClient);

    int status = 1;

    try{
        status = new ExportTool().run(sqoopClient);
    }
    return status;

Even tried executing throug command line
sqoop export --connect jdbc:oracle:thin:@192.168.2.175:1521:OPS1  --username ZYCDEV --password ZYCDEV --table abhishek_emp --update-key id --export-dir /user/abhisheks/bcr/check.txt --input-fields-terminated-by '|' --columns 'id,description' --update-mode updateonly

Still same issue..

我正在使用的cloudera版本是.. sqoop-1.4.2-cdh4.2.0.jar ..

最佳答案

这是一个错误。尝试使用较新版本的sqoop,并且运行良好。

09-26 17:48