0

utf8 文字を格納するように mysql 5.0 を構成しました。次のクエリで確認しました。


SELECT character_set_name FROM information_schema.`COLUMNS` C
WHERE table_schema = "oprdb"
  AND table_name = "rtable"
  AND column_name = "rtxt";

結果はutf8


SHOW FULL COLUMNS FROM rtable

これは私collationを次のように示していますutf8_general_ci


show variables like "character_set_database";
show variables like "collation_database";

これもutf8結果に表れる


mysqlが正しく構成されているようです。ユーザーがテキスト フィールドにテキストを入力する html ページからテキストを取得し、そのテキストを jquery post を使用してサーブレットに送信します。

私のhtmlページにはこれが一番上にあります--

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

これもフォームに追加しました-

enctype="text/plain;charset=UTF-8"

私のサーブレットでは、doPost の最初の行は

request.setCharacterEncoding("UTF-8");

その後、そのテキストをデータベースに保存するだけですが、問題は、この種のテキストを保存できないことです

 Hiki iaʻu ke ʻai i ke aniani; ʻaʻole nō lā au e ʻeha.
 Я магу есці шкло, яно мне не шкодзіц

私が見逃しているものはありますか?

編集:

これは私のデータソース構成です..

<Resource auth                = "Container" 
            driverClassName     = "com.mysql.jdbc.Driver" 
            factory             = "org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" 
            initialSize         = "10" 
            logAbandoned        = "true"
            maxActive           = "50" 
            maxIdle             = "2" 
            maxWait             = "10000" 
            name                = "jdbc/oprdb" 
            username            = "root"
            password            = "123456" 
            removeAbandoned     = "true" 
            removeAbandonedTimeout = "60"  
            type                   = "javax.sql.DataSource" 
            url                    = "jdbc:mysql://localhost:3306/oprdb" />
4

2 に答える 2

1

jdbc:mysql://localhost:3306/oprdb?useUnicode=true&characterEncoding=UTF-8 utf-8をサポートするためにURLをに更新します

于 2012-07-13T10:20:30.013 に答える
0

These are the only settings in MySQL Workbench in my system:

enter image description here

The result is the addition of these two lines:

character-set-server = utf8
character-set-filesystem = utf8

in the /etc/mysql/my.cnf file.

Make sure that the collation of your database table is utf8.

于 2012-07-13T10:26:23.003 に答える