Support Questions
Find answers, ask questions, and share your expertise
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


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( at org.apache.sqoop.manager.GenericJdbcManager.getConnection( at org.apache.sqoop.manager.SqlManager.execute( at org.apache.sqoop.manager.SqlManager.execute( at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery( at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery( at org.apache.sqoop.manager.SqlManager.getColumnTypes( at org.apache.sqoop.manager.ConnManager.getColumnTypes( at org.apache.sqoop.orm.ClassWriter.getColumnTypes( at org.apache.sqoop.orm.ClassWriter.generate( at org.apache.sqoop.tool.CodeGenTool.generateORM( at org.apache.sqoop.tool.ImportTool.importTable( at 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()); }



Re: Apache Sqoop: Sqoop using Java API


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


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