为什么需要转码? 生产需要,因为要做一系列的Insert操作,而且Insert语句中含中文字符。故如果informix默认是英文的话需要转码。如果默认是中文的话即不需要。这点一定要切记。 代码例子: /* * 如果databaseType字段为0说明为英文库。此时需要转码。否则就是中文库,不需要转码 */ if(rateModule.getDatabaseType().trim().equals("0")){ System.out.println("-------------------数据库为英文机,需要转码---------------"); for(int s=0; s<sqls.size(); s++){ //String sql=(String)sqls.get(s); //ps =conn.prepareStatement(sql); //System.out.println(sql); String str=new String(((String)sqls.get(s)).getBytes("GBK"),"ISO8859-1"); ps.addBatch(str); } }else{ System.out.println("-------------------数据库为中文机,不需要转码---------------"); for(int s=0; s<sqls.size(); s++){ //String sql=(String)sqls.get(s); //ps =conn.prepareStatement(sql); //System.out.println(sql); String str=new String(((String)sqls.get(s))); ps.addBatch(str); } }