message = new String(("round " + id).getBytes("UTF-8"));
conn = DriverManager.getConnection("jdbc:mysql://" + host + "/" + db + "?useUnicode=true&characterEncoding=UTF-8&"
+ "user=" + login + "&password=" + password);
當我插入數據庫的編碼是UTF-8 CI
,得到像這樣的�������������������� 179
,java文件編碼是UTF-8,我做錯了什麼?爲什麼java字符串沒有在MYSQL中保存爲UTF-8?
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
改變了所有,但我仍然得到那糟糕的編碼字符串 –
你重新啓動MySQL服務器? –
是的,編輯的問題... –