kettle使用文件导入到Postgresql出现如下几种问题的总结
1、kettle使用文件导入到Postgresql出现如下几种问题的总结:
1 kettle使用文件导入到Postgresql出现如下几种问题的总结: 2 1、第一种错误,报错如ERROR: extra data after last expected column所示。或者报错为报错为0x05,多一列,extra data after last expected column。 3 1)、sql查询语句定位到某个字段: 4 SELECT * from 数据表名称 where 字段名称 like CONCAT('%',char(5),'%') 5 2)、解决方法,使用空替代,原因是出现特殊字符,char(5),这种字符,导致的错误。 6 解决方法如下所示: 7 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { 8 Object[] r = getRow(); 9 10 if (r == null) { 11 setOutputDone(); 12 return false; 13 } 14 15 // It is always safest to call createOutputRow() to ensure that your output row’s Object[] is large 16 // enough to handle any new fields you are creating in this step. 17 r = createOutputRow(r, data.outputRowMeta.size()); 18 19 String 字段名称 = get(Fields.In, "字段名称").getString(r); 20 if(字段名称 != null) { 21 字段名称 = 字段名称.replaceAll((char)5 + "", ""); 22 } 23 get(Fields.Out, "字段名称").setValue(r, 字段名称); 24 25 // Send the row on to the next step. 26 putRow(data.outputRowMeta, r); 27 28 return true; 29 } 30 31 2、第二种错误,报错如missing data for column "datastamp"。 32 1)、sql查询语句定位到某个字段: 33 SELECT * from 数据表名称 where 字段名称 like CONCAT('%',char(10),'%') 34 或者 35 SELECT * from 数据表名称 where 字段名称 like CONCAT('%',char(13),'%') 36 2)、解决方法:是字段的值出现了,换行回车,char(10),char(13)。char(10)多一行,少n列,missing data column xxx。解决方法,使用字符替代,然后再替换回来。 37 解决方法如下所示: 38 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { 39 Object[] r = getRow(); 40 41 if (r == null) { 42 setOutputDone(); 43 return false; 44 } 45 46 // It is always safest to call createOutputRow() to ensure that your output row’s Object[] is large 47 // enough to handle any new fields you are creating in this step. 48 r = createOutputRow(r, data.outputRowMeta.size()); 49 50 String 字段名称 = get(Fields.In, "字段名称").getString(r); 51 if(字段名称 != null) { 52 字段名称 = 字段名称.replaceAll("\\r", "@#r;"); 53 字段名称 = 字段名称.replaceAll("\\n", "@#n;"); 54 } 55 get(Fields.Out, "字段名称").setValue(r, 字段名称); 56 57 // Send the row on to the next step. 58 putRow(data.outputRowMeta, r); 59 60 return true; 61 } 62 63 3、第三种错误,报错如,0x00的解决方法: 64 1)、sql查询语句定位到某个字段: 65 SELECT * from 数据表名称 where 字段名称 like CONCAT('%',char(0),'%') 66 2)、解决方法1 67 public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException { 68 Object[] r = getRow(); 69 70 if (r == null) { 71 setOutputDone(); 72 return false; 73 } 74 75 // It is always safest to call createOutputRow() to ensure that your output row’s Object[] is large 76 // enough to handle any new fields you are creating in this step. 77 r = createOutputRow(r, data.outputRowMeta.size()); 78 79 // Get the value from an input field 80 String 字段名称 = get(Fields.In, "字段名称").getString(r); 81 82 if(字段名称 != null) { 83 字段名称= 字段名称.replaceAll("\\u0000", ""); 84 } 85 86 get(Fields.Out, "字段名称").setValue(r, 字段名称); 87 88 // Send the row on to the next step. 89 putRow(data.outputRowMeta, r); 90 91 return true; 92 } 93
待续......
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?