Sqoop codegen

Let’s study about Sqoop codegen,

In this article will study about the importance of ‘codegen’ tool.

Features

* The codegen tool used to generates Java classes which encapsulate and interpret imported records.

* Codegen tool used to generate the DAO class automatically.

i.e DAO class contains ‘getter’ and ‘setter’ methods to initialize objects.

Advantage

* It will check the java code, in case java code is lost means it will regenerate new versions of a class using “codegen tool”.

Example

In this example, table “emp” contains employee data using codegen we are generating DAO class.

we can use below command to generate java code for “emp” table

$ sqoop codegen

–connect jdbc:mysql://localhost/beyondcorner

–username “root”

–password “beyonduser”

–table “emp”

Verification

The below command is used to verify generated java code

$ hadoop fs -ls  /home/beyondcorner/empjavacode/result

Reference

https://sqoop.apache.org/docs/1.4.6/SqoopUserGuide.html#_literal_sqoop_codegen_literal