连接Mysql编码问题

连接Mysql数据库的时候

     String url = "jdbc:mysql://localhost:3306/credit?autoReconnect=true&useUnicode=true&characterEncoding=utf8";
          String userName = "root";
            String password="root";

应该注意设置字符的编码;

如果是在XML文件中配置,则是 jdbc:mysql://localhost:3306/credit?autoReconnect=true&useUnicode=true&characterEncoding=utf8; 因为&就是&符号。

今天花了半天时间研究这个,记下来以防忘记。

关于编码问题有几篇文章供参考:

http://bbs.csdn.net/topics/390758162

http://www.cnblogs.com/gyjWEB/p/4600641.html

http://bbs.csdn.net/topics/390372335/

http://blog.sina.com.cn/s/blog_62aab2760100l1hx.html

 

posted @ 2016-12-17 16:45  GaryHostPublic  阅读(3170)  评论(0编辑  收藏  举报