Cloud Computing - Sqoop

Back to Course

Lesson Description

Lession - #797 Sqoop Codegen

This section portrays the significance of 'codegen' instrument. From the perspective of item arranged application, each database table has one DAO class that contains 'getter' and 'setter' strategies to instate objects. This device (- codegen>
creates the DAO class naturally. It creates DAO class in Java, in light of the Table Schema structure. The Java definition is launched as a piece of the import cycle. The fundamental utilization of this apparatus is to check assuming that Java lost the Java code. Provided that this is true, it will make another form of Java with the default delimiter between fields.


Below is the syntax for sqoop codegen command.
$ sqoop codegen (generic-args>
$ sqoop-codegen (generic-args>


Allow us to take a model that produces Java code for the employees table in the empoyee information base.

The accompanying order is utilized to execute the given model.
$ sqoop codegen \
--connect jdbc:mysql://localhost/userdb \
--username root \ 
--table employee

Above command shows the following output.
14/12/23 02:34:40 INFO sqoop.Sqoop: Running Sqoop version: 1.4.5
14/12/23 02:34:41 INFO tool.CodeGenTool: Beginning code generation
14/12/23 02:34:42 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /usr/local/hadoop
Note: /tmp/sqoop-hadoop/compile/9a300a1f94899df4a9b10f9935ed9f91/employees.java uses or 
   overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

14/12/23 02:34:47 INFO orm.CompilationManager: Writing jar file: 


Allow us to investigate the result. The way, which is in intense, is the area that the Java code of the emp table creates and stores. Allow us to check the records in that area utilizing the accompanying orders.
$ cd /tmp/sqoop-hadoop/compile/9a300a1f94899df4a9b10f9935ed9f91/
$ ls