常见乱码场景及解决方式

来源:互联网 发布:如何改变网络的拥堵 编辑:程序博客网 时间:2024/06/08 11:59

1、idea中用mybatis查询数据库中文乱码

在查询IP21实时数据库过程中,通过odbc-jdbc驱动取数,试过很多编码格式都是乱码

 while (rs.next() && index < 1000) {            for (int i = 1; i <= columnCount; i++) {                String result = rs.getString(i);                try {                    result = new String(result.getBytes(), "GBK");                } catch (UnsupportedEncodingException e) {                    e.printStackTrace();                }                System.out.print(autoBlank(result, 40));            }            System.out.println();            index++;        }

最后通过调整ide的编码格式解决