從Oracle數據庫讀取特殊字符(使用JDBC驅動程序和glassfish tooplink)時,我遇到問題。從Oracle數據庫中讀取Java的特殊字符
我通過WebService在數據庫上存儲名稱「GRØNLÅENKJÆTIL」,並在數據庫上存儲了正確的數據。
但是當我讀到這個字符串,打印日誌文件,並轉換成這字節數組絲毫驗證碼:
int pos = 0;
byte[] msg=new byte[1024];
String F = "F" + passenger.getName();
logger.debug("Add " + F + " " + F.length());
msg = addStringToArrayBytePlusSeparator(msg, F,pos);
..............
private byte[] addStringToArrayBytePlusSeparator(byte[] arrDest,String strToAdd,int destPosition)
{
System.arraycopy(strToAdd.getBytes(Charset.forName("ISO-8859-1")), 0, arrDest, destPosition, strToAdd.getBytes().length);
arrDest = addSeparator(arrDest,destPosition+strToAdd.getBytes().length,1);
return arrDest;
}
1)在日誌文件中有:「添加FGRÃNLÃ」(名稱不正確,F.length()未打印)。
2)代碼擲: java.lang.ArrayIndexOutOfBoundsException 在java.lang.System.arraycopy(本機方法) 在it.edea.ebooking.business.chi.control.VingCardImpl.addStringToArrayBytePlusSeparator(Test.java :225)。
任何解決方案?
坦克
如果我在Windows操作系統中運行該項目,這工作正常,但在Linux系統上問題仍然存在! – Luigi