Sqoop Codegen Command With Example

Sqoop Codegen Command With Example

This post describes the importance of 'codegen' tool. From the viewpoint of object-oriented application, every database table has one DAO class that contains 'getter' and 'setter' methods

It generates DAO class in Java, based on the Table Schema structure. The Java definition is instantiated as a part of the import process. The main usage of this tool is to check if Java lost the Java code. If so, it will create a new version of Java with the default delimiter between fields.

Step 1 - Change the directory to /usr/local/hadoop/sbin

$ cd /usr/local/hadoop/sbin

Step 2 - Start all hadoop daemons.

$ start-all.sh

Step 3 - The JPS (Java Virtual Machine Process Status Tool) tool is limited to reporting information on JVMs for which it has the access permissions.

$ jps

Step 4 - Change the directory to /usr/local/sqoop/bin

$ cd /usr/local/sqoop/bin


$ sqoop codegen \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root \
--table employee

If the command executes successfully, then it will produce the following output on the terminal.

$ /tmp/sqoop-hduser/compile/0607f608c40d5860029a2132208e5912


Let us take a look at the output. The path, which is in bold, is the location that the Java code of the emp table generates and stores. Let us verify the files in that location using the following commands.

$ cd /tmp/sqoop-hduser/compile/0607f608c40d5860029a2132208e5912
$ ls
employee.class,employee.java ,employee.jar

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *