java中的weired character handling

时间:2016-08-20 03:22:17

标签: java

我正从DB表中检索数据。 在数据库表格中,我已经提供了字符值,例如ñ
(虽然有很多,我只能在这篇文章中复制这个。其他例如A和它上面的字符如^等)

当我尝试从数据库中检索并放入我的hashMap时,它显示出奇怪的行为。 1)地图的实际计数与数据库表计数不同(计数较少)(可能跳过某些字符行但不确定原因)

2)当我打印hashMap时,我看到的是 - 它已经添加了?那里。

Map m = new HashMap();
rs= statement.execteQuery("select A,B from table Test");
while(rs.next()){
 map.put(rs.getString("A"),rs.getString("B"));
}

Iterator itr = map.entrySet().iterator();
while(itr.hasNext()){
Map.Entry m = (Map.Entry) itr.nxt();
System.out.println(m.getKey() + m.getValue()); // Here different values placed in Map instead actual values
}

如何处理这些奇怪的行为和角色?

感谢。

0 个答案:

没有答案