温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

kettle使用文件导入到Postgresql出现乱码的解决方法

发布时间:2020-07-31 11:20:36 来源:亿速云 阅读:202 作者:清晨 栏目:编程语言

小编给大家分享一下kettle使用文件导入到Postgresql出现乱码的解决方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

kettle使用文件导入到Postgresql出现如下几种问题的总结:

第一种错误,报错如ERROR:  extra data after last expected column所示。或者报错为报错为0x05,多一列,extra data after last expected column。

sql查询语句定位到某个字段:

SELECT * ),'%')

解决方法,使用空替代,原因是出现特殊字符,),这种字符,导致的错误。

解决方法如下所示:

 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
     Object[] r = getRow();
 
     if (r == null) {
     setOutputDone();
     return 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, data.outputRowMeta.size());
 
     String 字段名称 = get(Fields.In, "字段名称").getString(r);
     if(字段名称 != null) {
         字段名称 = 字段名称.replaceAll(( + "", "");
     }
     get(Fields.Out, "字段名称").setValue(r, 字段名称);
 
     // Send the row on to the next step.
     putRow(data.outputRowMeta, r);
 
     return true;
 }

第二种错误,报错如missing data for column "datastamp"。

sql查询语句定位到某个字段:

SELECT * ),'%')

或者

 SELECT * ),'%')

解决方法:是字段的值出现了,换行回车,),)。)多一行,少n列,missing data column xxx。解决方法:使用字符替代,然后再替换回来。

解决方法如下所示:

 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
     Object[] r = getRow();
 
     if (r == null) {
     setOutputDone();
     return 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, data.outputRowMeta.size());
 
     String 字段名称 = get(Fields.In, "字段名称").getString(r);
     if(字段名称 != null) {
         字段名称 = 字段名称.replaceAll("\\r", "@#r;");
         字段名称 = 字段名称.replaceAll("\\n", "@#n;");
     }
     get(Fields.Out, "字段名称").setValue(r, 字段名称);    
 
     // Send the row on to the next step.
     putRow(data.outputRowMeta, r);
 
     return true;
 }

第三种错误,报错如,0x00的解决方法:

sql查询语句定位到某个字段:

SELECT * ),'%')

解决方法:

 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
     Object[] r = getRow();
 
     if (r == null) {
     setOutputDone();
     return 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, data.outputRowMeta.size());
 
     // Get the value from an input field
     String 字段名称 = get(Fields.In, "字段名称").getString(r);
 
     if(字段名称 != null) {
         字段名称= 字段名称.replaceAll("\\u0000", "");
     }
 
     get(Fields.Out, "字段名称").setValue(r, 字段名称);
 
     // Send the row on to the next step.
     putRow(data.outputRowMeta, r);
 
     return true;
 }

看完了这篇文章,相信你对kettle使用文件导入到Postgresql出现乱码的解决方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI