Sample program to convert and work in pentahome kettle using Java (eclipse)

Hi I'm very new to pentaho teapot. I want a sample program that takes input from a .csv file and inserts into a database, and after a certain time like 2:30 a job will run and multiple records from that database (sql developer) in csv format will be sent by email to the user. I am using Java to trigger a transformation like:

public static void main(String[] args) {
    try {
            KettleEnvironment.init();
            TransMeta metaData = new TransMeta("hello.ktr");
            Trans trans = new Trans( metaData );
            trans.execute( null );
            trans.waitUntilFinished();
            if ( trans.getErrors() > 0 ) {
                System.out.print( "Error Executing transformation" );
            }
    } 
    catch( KettleException e ) {
            e.printStackTrace();
    }
}

      

Here I created HelloWorld (hello.ktr) program in Spoon and named it in java code. I want to do this. Converting and working in a spoon and calling in my Java code. kindly help me with this.

+3


source to share


1 answer


Why aren't you planning to run the program at 2:30 am using crontab? In lunux, create a script how you want like start.sh and add the following script code:

#!/bin/bash
30 2 * * * /root/transScript.sh /dev/null 2>&1 | mail -s "Cronjob ouput" saket@gmail.com

      

Then create another script, possibly named transScript, like /root/transScript.sh, and add the following to the script to trigger the panning transformation. pan is a tool that manages the conversions of dummies via the command line. To complete tasks in caches using the command line, you need to use the kitchen.



$ cat pdi.sh
#!/bin/bash
/opt/data-integration/pan.sh -file=/Users/saket/Transformations/hello.ktr 
/level:Basic

      

Then all you have to do is run this command to start the scheduled task:

crontab start.sh

      

0


source







All Articles