生活随笔
收集整理的這篇文章主要介紹了
Kettle调用Java类
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.新建Java測試類,導出Jar包,放在kettle目錄中的libext文件中
package?test;?public?class?Test{?????public?static?final?String?getMyName(String?name){?????????return?name+"12345";?????}?}
2.抽數據--經過java處理--輸出文件到桌面
import?test.Test;??public?boolean?proce***ow(StepMetaInterface?smi,?StepDataInterface?sdi)?throws?KettleException?{?????Object[]?r?=?getRow();?????if?(r?==?null)?{?????????setOutputDone();?????????return?false;?????}??????if?(first)?????{?????????first?=?false;?????}??????//?It?is?always?safest?to?call?createOutputRow()?to?ensure?that?your?output?row's?Object[]?is?large?????//?enough?to?handle?any?new?fields?you?are?creating?in?this?step.?????//r?=?createOutputRow(r,?outputRowSize);??????????/*?TODO:?Your?code?here.?(See?Sample)??????????/?Get?the?value?from?an?input?field?????String?foobar?=?get(Fields.In,?"a_fieldname").getString(r);??????foobar?+=?"bar";??????????//?Set?a?value?in?a?new?output?field?????get(Fields.Out,?"output_fieldname").setValue(r,?foobar);??????*/??????//調用jar?????String?foobar?=?get(Fields.In,?"ENAME").getString(r);?//輸入參數?????foobar?+=?Test.getMyName("我是誰的水");?????get(Fields.Out,?"ENAME").setValue(r,?foobar);???????????//獲取參數??????String?AGEField?=?getParameter("AGE");??????get(Fields.Out,?"AGE").setValue(r,?AGEField);?//輸出參數???????????//?Send?the?row?on?to?the?next?step.?????putRow(data.outputRowMeta,?r);??????return?true;?}? ?
轉載于:https://blog.51cto.com/programmer/1164002
總結
以上是生活随笔為你收集整理的Kettle调用Java类的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。