1、kettle 维度更新
代理关键字 增加的时候 ,其 FID类型最大只能设置 NUMBER(17),否则报错 ,数据库:ORACLE
2、利用kettle发邮件附件,下面是流程图:
3、利用kettle jar包执行kettle生成的ktr和kjb文件,这里给大家一个我配置好的java工程,大家可以通过TestRunKettle执行kettle生成的文件, 点击下载kettle演示工程
4、支持jasper图形邮件发送的EMAIL插件修改
//start html email 将HMTL文件写入邮件流里面
InputStream is = file.getContent().getInputStream();
if(is!=null && file.getName().getExtension().equals("html")){
// System.out.println(file.getName().getExtension());
//set html to a string
MimeBodyPart htmlContent = new MimeBodyPart();
byte[] bytes = new byte[1024];
String html = "";
int c;
while((c=is.read(bytes))!=-1){
html = html + new String(bytes,0,c);
}
// System.out.println(html);
//replace the image url with new cid url
String IMG_REGEX = "<\s*img\s+(?:[^\s>]\s*){0,}src\s*=\s*["']\s*([^"'\s>]*)\s*["'](?:\s*[^\s>]){0,}\s*>";
String PREFIX_IMG = "img_";
Map urlMap = new HashMap();
Pattern p = Pattern.compile(IMG_REGEX);
Matcher m = p.matcher(html);
String url = null;
String cid = null;
int i = 1;
// replace image url
while (m.find()) {
url = m.group(1);
if (StringUtils.hasText(url)) {
if (!urlMap.containsKey(url)) {
cid = PREFIX_IMG+(i++);
urlMap.put(url, cid);
html = html.replaceAll(url, "cid:"+cid);
}
}
}
//add html into email
htmlContent.setContent(html, "text/html; " + "charset=utf-8");
parts.addBodyPart(htmlContent);
//add html's image into email
Iterator urlIterator = urlMap.keySet().iterator();
while (urlIterator.hasNext()) {
url = urlIterator.next();
cid = urlMap.get(url);
MimeBodyPart imageFile = new MimeBodyPart();
byte [] imageBytes = file2byte(url);
DataHandler dh = new DataHandler(new ByteArrayDataSource((byte[])imageBytes,"application/octet-stream"));
imageFile.setDataHandler(dh);
imageFile.setFileName(cid);
// imageFile.setHeader("Content-ID", "IMG" + new Integer(i).toString());
parts.addBodyPart(imageFile);
// System.out.println(html);
// System.out.println(cid);
}
}
//end html email
5、关于kettle使用的数据源,这里面会涉及到2个数据源,一个是全局数据源,还有一个是XML中自身的数据源,其中全局的会覆盖XML自身的。记住这个规则就可以了



你好,我想请问下关于改动后如何打包kettle的细节
eclipse是自带打包工具的,你可以试试
你好,从您的博文中学到了很多,谢谢。
我在使用kettle 4.4 与hive创建连接的时候,
遇到了窗口弹出式的错误。
我的hadoop版本是apache0.23.5
hive是0.81的。
很想请教如果您遇到类似错误,是如何解决的。谢谢。
连接hive我没有玩过,不知道你弹出来的错误是什么? 你可以贴出来看看。另外,可以看看连接hive的驱动是不是在文件夹libextJDBC里面,你可以找连接hive 0.81的驱动jar包替换kettle里面的试试。
你好,
十分感谢,
报错的信息其中几条是:
Error connecting to database :
(using class org.apache.hadoop.hive.jdbc.HiveDriver)
org/apache/hadoop/hive/metastore/api/MetaException
org.pentaho.di.core.exception.KettleDatabaseException:
Error occured while trying to connect to the database
我已经把包相应的加载到相应的路径下了,
但是,并不解决问题。
我想应该是底层hadoop版本不兼容吧。
我想请问能否使用从新写一个插件的方式来进行加载。
能否可行呢?您能说说您的思路吗?
谢谢 ^-^
企业hadoop应用建议使用1.0.3 ,hive 本身其实是有写数据的API,不推荐使用jdbc的方式,如果你要写kettle的插件,我给个例子你:http://www.ahuoo.com/?p=418
你好,
谢谢你。:-)