資料庫亂碼解決,應注意事項 –struts+spring+hibernate環境下

來源:互聯網
上載者:User

    在struts+spring+hibernate環境下設定資料庫,要讓資料庫顯示中文,需要修改資料目錄/下的my.ini檔案(我用得是mysql),修改兩處地方如下,紅色字型為要修改的地方

client]

port=3306

[mysql]

default-character-set=gb2312

# SERVER SECTION
# ----------------------------------------------------------------------
#
# The following options will be read by the MySQL Server. Make sure that
# you have installed the server correctly (see above) so it reads this
# file.
#
[mysqld]

# The TCP/IP Port the MySQL Server will listen on
port=3306

#Path to installation directory. All paths are usually resolved relative to this.
basedir="C:/Program Files/MySQL/MySQL Server 5.0/"

#Path to the database root
datadir="C:/Program Files/MySQL/MySQL Server 5.0/Data/"

# The default character set that will be used when a new schema or table is
# created and no character set is defined
default-character-set=gb2312

記住以下幾點:

   1、一定要兩個地方同時修改,否則還會顯示亂碼

  2、修改完了以後要記得把原先的資料庫,表重建立立一遍,否則程式會出現問題(具體原因我也不是很清楚啊)。

   3、搞定以上兩點後重新啟動以下資料庫伺服器即可。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.