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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM