Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Apache Sqoop: Sqoop using Java API

Highlighted

Apache Sqoop: Sqoop using Java API

I am using HDP 2.4 and created a SQOOP API via scala code. Now, when I am running the sqoop command it is running fine with data being loaded in the HDFS but whenever I use the Java API I am getting this error:

Exception in thread "main" java.lang.RuntimeException: Could not load db driver class: oracle.jdbc.OracleDriver at org.apache.sqoop.manager.OracleManager.makeConnection(OracleManager.java:286) at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52) at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:744) at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:767) at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:270) at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:241) at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:227) at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295) at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1845) at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1645) at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:107) at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:478) at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605) at master.invoker.tester$.main(tester.scala:158) at master.invoker.tester.main(tester.scala)

It is like when I am running with the API, It is unable to find the lib of SQOOP. This is the Scala code used to run Sqoop in Java API.

var url="jdbc:oracle:thin:@//<IP>:<PORT>/<SID>"

var user="xxx"

var password="xxx"

val tool:SqoopTool = new ImportTool()

val args: Array[String] = Array("--connect", url, "--username", user, "--password", password, "--table", "<tablename>")

var options:SqoopOptions = new SqoopOptions();

try {

options = tool.parseArguments(args, null, options, false); tool.validateOptions(options);

} catch {

case e: Exception => { System.err.println(e.getMessage()); }

}

tool.run(options)

2 REPLIES 2
Highlighted

Re: Apache Sqoop: Sqoop using Java API

Explorer

As I know, you don't need to specify oracle jdbc driver parameter in cmd.

Highlighted

Re: Apache Sqoop: Sqoop using Java API

I didn't. I just passed the url, username, password and the table name

val args: Array[String] = Array("--connect", url, "--username", user, "--password", password, "--table", "<tablename>")

Don't have an account?
Coming from Hortonworks? Activate your account here