哈,又是編碼問題。本來用 WebSphere 和 DB2 的環境,資料新增至資料庫中文都沒問題,怎麼一換到 tomcat 和 MySQL 這組合就中文新增到資料庫時就變成了問號。

最後試驗的結果,需在 connection string 加上 useUnicode=true&characterEncoding=utf8 這段設定,這樣中文新增到資料庫就會正常了,不會再是?字元。

JDBC use like
String conString = "jdbc:mysql://host/database?useUnicode=true&characterEncoding=utf8";

DataSource resource url like
url="jdbc:mysql://host/database?useUnicode=true&characterEncoding=utf8"

arrow
arrow
    文章標籤
    MySQL
    全站熱搜

    mark528 發表在 痞客邦 留言(0) 人氣()