5
0
mirror of https://github.com/apache/sqoop.git synced 2025-05-03 23:09:50 +08:00

SQOOP-2896: Sqoop exec job fails with SQLException Access denied for user

(Sowmya Ramesh via Venkat Ranganathan)
This commit is contained in:
Venkat Ranganathan 2016-03-29 18:02:19 -07:00
parent 1dd50cfb2a
commit 729e681f10

View File

@ -28,6 +28,7 @@
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.ParseException;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@ -50,6 +51,7 @@ public class JobTool extends com.cloudera.sqoop.tool.BaseSqoopTool {
public static final Log LOG = LogFactory.getLog(
JobTool.class.getName());
private static final String DASH_STR = "--";
private enum JobOp {
JobCreate,
@ -210,6 +212,34 @@ private int execJob(SqoopOptions opts) throws IOException {
SqoopOptions clonedOpts = (SqoopOptions) childOpts.clone();
clonedOpts.setParent(childOpts);
String [] childArgv = childOpts.getExtraArgs();
if (childArgv == null || childArgv.length == 0) {
childArgv = new String[0];
}
int dashPos = getDashPosition(extraArguments);
if (dashPos < extraArguments.length) {
String[] extraArgs = Arrays.copyOfRange(extraArguments, dashPos + 1,
extraArguments.length);
if (childArgv == null || childArgv.length == 0) {
childArgv = extraArgs;
} else {
// Find the second dash pos
int dashPos2 = getDashPosition(extraArgs);
if (dashPos2 >= extraArgs.length) {
// if second dash is not present add it
extraArgs = ArrayUtils.addAll(extraArgs, DASH_STR);
}
childArgv = ArrayUtils.addAll(extraArgs, childArgv);
}
}
int confRet = configureChildTool(clonedOpts, childTool, childArgv);
if (0 != confRet) {
// Error.
return confRet;
}
return childTool.run(clonedOpts);
}