tomcat新增資料到mysql中文亂碼

2021-08-15 17:40:37 字數 605 閱讀 3467

一、問題分析

當新增資料到資料庫出現亂碼時,首先考慮資料庫的編碼格式。這裡我們統一使用utf-8。其次考慮tomcat的設定,是否有字符集的設定。

二、解決方法

1、mysql資料庫編碼格式

show variables like '%char%';-----檢視資料庫編碼格式

檢視以上五項是否是utf-8,如果不是,使用

set character_set_database = utf8;

----設定編碼格式

最後重啟mysql再檢視資料庫編碼格式

(如果以上沒有生效

可以去在/etc/my.cnf檔案中[mysqld]下增加

character-set-server=utf8

重啟mysql)

2、tomcat編碼格式設定

只需要在server.xml檔案中新增

重啟tomcat生效

Tomcat 中如何新增資料庫驅動

tomcat中如何新增資料庫驅動 jdbc 驅動的jar 檔案 orcal,mysql,sql server 二 講所需的驅動的 jar檔案拷貝到 tomcatroot common lib 下即可 例如本機路徑為 c program files apache software foundation...

PHP MySQLi STMT新增資料

php mysqli stmt 新增資料 預編譯 1.建立mysqli物件 mysqli new mysqli localhost root 1234 test 2.建立預編譯物件 sql insert into user1 name,password,email,age values mysqli...

ExtJs gridPanel新增資料

向gridpanel新增資料 資料模型 ext define xx xxmodel 一 當gridpanel讀取的是資料庫的資訊時me.store ext.create ext.data.store listeners load function store,records,successful,e...