仅在Grails数据库表中使用UTF-8 [英] UTF-8 only in Grails database tables

查看:108
本文介绍了仅在Grails数据库表中使用UTF-8的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Grails 1.0.4和MySQL时,自动生成的数据库表的字符集似乎默认为ISO-8859-1。我宁愿将所有内容都存储为纯UTF-8格式。这可能吗?



从自动生成的数据库定义:

  ENGINE = MyISAM AUTO_INCREMENT = 1 DEFAULT CHARSET = latin1; 

请注意latin1部分。

解决方案

大多数MySQL安装默认为latin1,所以如果没有其他指示,驱动程序将会默认值。例如:


jdbc:mysql://在连接URL中预先填充charset指令就足够了。 localhost / databaseName?useUnicode = yes& characterEncoding = UTF-8


连接器JAR必须是版本5(3.x将不起作用)。



来源: MySQL参考手册:使用字符集和Unicode


When using Grails 1.0.4 together with a MySQL the charsets of the auto-generated database tables seem to default to ISO-8859-1. I'd rather have everything stored as pure UTF-8. Is that possible?

From the auto-generated database definitions:

ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;

Note the "latin1" part.

解决方案

Most MySQL installations default to latin1, so if not instructed otherwise, the driver will go by the default values. It should suffice to prepend the charset directives in the connection URL, for example:

jdbc:mysql://localhost/databaseName?useUnicode=yes&characterEncoding=UTF-8

For this to work, the MySQL Connector JAR must be of version 5 (3.x will not work).

Source: MySQL Reference manual: Using Character Sets and Unicode

这篇关于仅在Grails数据库表中使用UTF-8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆