Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

Apache Sqoop : How Sqoop can be used with Java API

avatar
Expert Contributor

Do any one help me to write Sqoop script with Java API ?

1 ACCEPTED SOLUTION

avatar
Expert Contributor

@Amit Dass

Take a look here to start with.

View solution in original post

4 REPLIES 4

avatar
Expert Contributor

@Amit Dass

Take a look here to start with.

avatar
Master Guru

Here is an example of using the SQOOP API

https://gist.github.com/umbertogriffo/5ddb75bda34a99a427ff

Just use NIFI, why write a whole Java app?

Or just schedule SQOOP with OOZIE

avatar
Expert Contributor
Issue in Sqoop :  Oracle database to hdfs

17/03/02 19:44:28 WARN sqoop.ConnFactory: Parameter --driver is set to an explicit driver however appropriate connection manager is not being set (via --connection-manager). Sqoop is going to fall back to org.apache.sqoop.manager.GenericJdbcManager. Please specify explicitly which connection manager should be used next time.
17/03/02 19:44:28 INFO manager.SqlManager: Using default fetchSize of 1000
17/03/02 19:44:28 INFO tool.CodeGenTool: Beginning code generation
17/03/02 19:44:40 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM ABCSCHEMA.ABCTABLE AS t WHERE 1=0
17/03/02 19:44:40 ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:445)
        at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
        at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:879)

Solution : 
1.Table name should be capital :
SqoopOptions.setTableName("ABCSCHEMA.ABCTABLE");
String[] cols={"E_DATE","E_CATEGORY","E_COMPUTER","U_NAME","IPADDRESS","D_NAME","R_INSERT_DATE"};
SqoopOptions.setColumns(cols);
SqoopOptions.setWhereClause("R_INSERT_DATE >=to_date('31-12-1900','DD-MM-YYYY')");

2. Dont Specify Driver name in your program using below commands (refer this  : https://issues.apache.org/jira/browse/SQOOP-457 )

So below lines not required in your program :
    // SqoopOptions.setDriverClassName(DriverDomain);
   //SqoopOptions.setConnManagerClassName("org.apache.sqoop.manager.GenericJdbcManager");



avatar
Expert Contributor

Provided solution for "java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended"