eclipse向MySQL workbench插入中文顯示亂碼

eclipse向MySQL workbench插入中文顯示亂碼

問題描述如下:我們在eclipse中向MySQL中插入數據

statement.executeUpdate("INSERT INTO word VALUES'鮮花''2')");

然而我們發現
這裏寫圖片描述
解決方法:我們爲mysql數據庫的連接字符串設置編碼方式
將原先的代碼

Connection  c =DriverManager.getConnection("jdbc:mysql://localhost:3306/words","root","");

修改爲

Connection c
 =DriverManager.getConnection("jdbc:mysql://localhost:3306/words?characterEncoding=utf8","root","");
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章