码迷,mamicode.com
首页 > 数据库 > 详细

连接Mysql编码问题

时间:2016-12-17 19:36:50      阅读:208      评论:0      收藏:0      [点我收藏+]

标签:连接   user   字符   topic   数据   问题   connect   cte   utf8   

连接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

 

连接Mysql编码问题

标签:连接   user   字符   topic   数据   问题   connect   cte   utf8   

原文地址:http://www.cnblogs.com/GaryHostPublic/p/6192608.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!