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