文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Grails数据库及中文配置

Grails数据库及中文配置

时间:2009-04-19  来源:cmm_brandon

1.数据库配置文件内容:
dataSource {
    pooled = false
    driverClassName = "com.mysql.jdbc.Driver"
    username = "root"
    password = "123456"
}
hibernate {
    cache.use_second_level_cache=true
    cache.use_query_cache=true
    cache.provider_class='org.hibernate.cache.EhCacheProvider'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop','update'
            url = "jdbc:mysql://localhost:3306/Disc_dev?useUnicode=true&characterEncoding=UTF-8"
            //logSql=true
        }
    }
    test {
        dataSource {
            dbCreate = "create"
            url = "jdbc:mysql://localhost:3306/Disc_test?useUnicode=true&characterEncoding=UTF-8"
        }
    }
    production {
        dataSource {
            dbCreate = "create"
            url = "jdbc:mysql://localhost:3306/Disc_res?useUnicode=true&characterEncoding=UTF-8"
        }
    }
}
这个配置说明开发使用的是MySql数据库,因为驱动程序是com.mysql.jdbc.Driver, 用户名:root,密码:123456。
在配置文件里配置了三个数据源,分别对应Grails的开发(development),测试(test)和部署(production)数据库。在dataSource里使用logSql的原因是在控制台输出sql语句方便调试。
2. 关于Grails的中文配置
(1)对Grails生成的文件不作任何编码上的改动。
(2)数据库需要配置使用UTF-8编码。如果使用MySql数据库,需要修改my.ini文件,在client section, mysql section 以及mysqld section里把default-character-set的属性改为utf8.
(3)要在页面中使用文字,应该建立Grails字符串资源,同时在页面中使用<g:message>标签来访问。这样可以保证页面的跨语言属性。
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载