3
votes

Hi i am very new to pentaho kettle-spoon. I want a sample program which takes input from .csv file and push into database and after certain time like 2:30 am a job will run and few records from that database(sql developer) in csv format will emailed to user. I am using Java to call the 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 have created HelloWorld(hello.ktr) program in Spoon and called it in java code. I want to do similar. Making transformation and job in spoon and calling in my java code. kindly help me out with it.

1
Fail fast! That Pentaho suit is trash and was the source of a lot of the issues we had in one of the systems I worked with recently. If you can find another solution in your problem you should.DroidT
Actually i need to do sample program(how to initiate with the suite) and merge with java. Just want to check if its working. If you can share a sample that would be helpful for now. ThanksSaket
DroidT, can you elaborate on what problems you had, I am in the process of choosing a solution for my company and this could be useful info in making a decision, thanksVijay Kumar

1 Answers

0
votes

Why don't you schedule the program to run at 2:30AM using crontab? In lunux, create a script called whatever you want e.g start.sh and add the following script code:

#!/bin/bash
30 2 * * * /root/transScript.sh /dev/null 2>&1 | mail -s "Cronjob ouput" [email protected]

Then create another script maybe called transScript like /root/transScript.sh and add the following in script to run the transformation using pan. pan is the tool that runs kettle transformations via the command line. For running kettle jobs via command line, you have to use 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 begin the scheduled task:

crontab start.sh