This topic has been archived. It cannot be replied.
-
工作学习 / 学科技术讨论 / 被一个问题困惑了几天,望有人帮助.一Java Web App, 和第一个MySql DB Schema连接,UTF8没有任何问题,再和另一个schema相连,从DB读UTF8没有问题,但往里写UTF8就是乱码.DB default cha set, request, response, jdbc connection string, table language option, etc, etc, 都查过了....
-nicetomeetyou(轻松淡定灌筑江山);
2010-2-27
{112}
(#5910625@0)
-
问一个比较弱的问题(因为没有用过MySQL),以UTF8的格式写数据库?数据库内部以UTF8保存?
-urmylove(麻袋);
2010-2-28
(#5912466@0)
-
好像是这样的。
-registereduser(立牌坊);
2010-3-2
(#5916974@0)
-
数据库内部用UCS-2保存应该会更好点吧。
-urmylove(麻袋);
2010-3-2
(#5916979@0)
-
你讲的是UTF-16?MySQL 好像到现在为止并不支持16位元。
-registereduser(立牌坊);
2010-3-2
(#5917001@0)
-
噢!谢谢!
-urmylove(麻袋);
2010-3-2
(#5917013@0)
-
我曾经在PHP中也遇到过这个情况。
-registereduser(立牌坊);
2010-3-2
(#5916973@0)
-
你后来怎么解决的? 都改用一个SCHEMA?
-nicetomeetyou(轻松淡定灌筑江山);
2010-3-2
(#5919212@0)
-
这是我的方法。不知对你有没用。
-registereduser(立牌坊);
2010-3-3
{952}
(#5921774@0)
-
The way of handling UTF8 is similar in Java Web code. It is an Ajax http post request to send form info to server. When posted data is read back from response, it displays OK on web page. But it becomes crappy when saved into table.But if you put UTF8 text in table, and let system read it and display on web, no problem at all.
The above is for the second web application. for another application on another schema, both read / write work fine.
Two applications are sharing basically the same codeset.
In Mysql, table's charset is utf8, collation is utf8_general_ci. default chaeset for database is utf8.
-nicetomeetyou(轻松淡定灌筑江山);
2010-3-3
{385}
(#5922088@0)
-
I had same problem as what you have, unable to write into database properly.That was because I used some other codes for which I could remember now. In some classes it worked while in other classes it did not work. I was never being able to figure out what was wrong.
After I changed to mysql_query("SET NAMES 'UTF8'"), all problems disappeared.
-registereduser(立牌坊);
2010-3-4
{276}
(#5922126@0)
-
Actually in your MySQL, it looks like a crappy, but indeed it is not.
-registereduser(立牌坊);
2010-3-4
{529}
(#5922150@0)
-
I actually have two lines..:-). I can see Chinese right in the table, right after the text is written down through the first application. But for the second app, the text is crappy.stmt.execute("SET NAMES 'utf8'");
stmt.execute("SET CHARACTER SET 'utf8'");
The only difference between two apps is: I use normal form post in the first app, and Ajax post in the second app. I traces those texts all the way posted to server, to DB, the problem is probably in jdbc connection, but I have similar connection string between two apps....
jdbc:mysql://xxx.xxx.xxx.xxx:xxxx/db_name?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8
11.
-nicetomeetyou(轻松淡定灌筑江山);
2010-3-4
{486}
(#5922162@0)
-
If I were you , I would try to remove stmt.execute("SET CHARACTER SET 'utf8'") to see if it does work.
-registereduser(立牌坊);
2010-3-4
(#5922171@0)
-
你还别说:你对了!!!有饭局的时候,一定要叫上我.
-nicetomeetyou(淡定灌水);
2010-3-7
(#5929000@0)
-
你没蒙我?我太高兴了。我当时就是这么蒙出来的。没法弄明白里面的道理。牛哥一直是我的崇拜对象。
-registereduser(立牌坊);
2010-3-8
{24}
(#5931580@0)
-
我也不知道为什么. 哈哈.
-nicetomeetyou(淡定灌水);
2010-3-8
(#5931682@0)
-
UTF8 和 XML-UTF8是有区别的,是不是因为这原因?
-frankwoo(柳五随风);
2010-3-8
(#5932025@0)
-
不明白你说的XML-UTF8..? 写DATA时用的是standard JDBC API, setString(), 和XML没关系.
-nicetomeetyou(淡定灌水);
2010-3-9
(#5932372@0)
-
我胡乱猜测呢,刚才google了一下,感觉和MySql的unicode mapping table有关系,另外呢有人提到了Clinent-Server shakehands,感觉好像是Database server通过检测client的locale Code page从而确定采用何种unicode mapping有关系(夏猜测的)
-frankwoo(柳五随风);
2010-3-9
(#5934862@0)
-
Interesting! Can you put more detail on "locale Code page"? At app level, for example, request/response model, how to check it?
-nicetomeetyou(淡定灌水);
2010-3-10
(#5936550@0)
-
牛歌, 根据你问这个问题, 说明你还不能实现: 根据CLIENT的BROWSER LANGUAGE, 自动显示相对应的多国语言. 就象GOOGLE, YAHOO...它们能自动显示.
-whereismyid(到处找ID);
2010-3-11
(#5937655@0)
-
I leave it to user to decide, if the app is a portal. When user first contact app, he will choose his favored lang option, color scheme option, date/time format, various hide-when, and those options will saved in his profile andwill be immediately available in next visit after login.
I just make sure what I deliver is a UTF-8 page.
-nicetomeetyou(淡定灌水);
2010-3-11
{108}
(#5937815@0)
-
PM me your phone number, I hope I can help you, Sir.
-birdjay(JayBird);
2010-3-11
(#5939337@0)
-
大侠,帮我看一下我的方法管不管用:
-registereduser(立牌坊);
2010-3-14
{896}
(#5944947@0)
-
难道是BOM的问题?另一个不是好好的吗。
-urmylove(麻袋);
2010-3-2
(#5916984@0)
-
在什么地方看到的乱码?
-urmylove(麻袋);
2010-3-2
(#5916986@0)
-
先瞎猜一个。。另外,牛哥用什么TRACER? 应该有些详情数据出来。。。
-firetrain(火车头);
2010-3-2
(#5917077@0)
-
钓鱼贴??
-urmylove(麻袋);
2010-3-2
(#5917556@0)