溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

kettle使用文件導(dǎo)入到Postgresql出現(xiàn)亂碼的解決方法

發(fā)布時間:2020-07-31 11:20:36 來源:億速云 閱讀:219 作者:清晨 欄目:編程語言

小編給大家分享一下kettle使用文件導(dǎo)入到Postgresql出現(xiàn)亂碼的解決方法,希望大家閱讀完這篇文章后大所收獲,下面讓我們一起去探討吧!

kettle使用文件導(dǎo)入到Postgresql出現(xiàn)如下幾種問題的總結(jié):

第一種錯誤,報錯如ERROR:  extra data after last expected column所示。或者報錯為報錯為0x05,多一列,extra data after last expected column。

sql查詢語句定位到某個字段:

SELECT * ),'%')

解決方法,使用空替代,原因是出現(xiàn)特殊字符,),這種字符,導(dǎo)致的錯誤。

解決方法如下所示:

 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 * ),'%')

解決方法:是字段的值出現(xiàn)了,換行回車,),)。)多一行,少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使用文件導(dǎo)入到Postgresql出現(xiàn)亂碼的解決方法有了一定的了解,想了解更多相關(guān)知識,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI