- 爱易网页
-
数据库教程
- Grails配备外部数据库
日期:2014-05-16 浏览次数:20491 次
Grails配置外部数据库
在Grails项目中的conf文件夹下如图
打开DataSource文件作如下配置
这里链接的是mysql数据库
dataSource {
//连接池打开
??? pooled = true
//驱动名字
??? driverClassName = “com.mysql.jdbc.Driver”
//用户名
??? username = “root”
//密码
password = “root”
//数据库方言
??? dialect = org.hibernate.dialect.MySQL5InnoDBDialect
}
hibernate {
??? cache.use_second_level_cache = true
??? cache.use_query_cache = true
??? cache.provider_class = ‘net.sf.ehcache.hibernate.EhCacheProvider’
}
// 不同的模式
environments {
//开始模式
??? development {
??????? dataSource {
??????????? dbCreate = “update” // one of ‘create’, ‘create-drop’,'update’
??????????? url = “jdbc:mysql://localhost:3306/gralis?useUnicode=true&characterEncoding=UTF-8″
??????? }
??? }
//测试模式
??? test {
??????? dataSource {
???????????? dbCreate = “update” // one of ‘create’, ‘create-drop’,'update’
??????????? url = “jdbc:mysql://localhost:3306/gralis?useUnicode=true&characterEncoding=UTF-8″
??????? }
??? }
//发布模式
??? production {
??????? dataSource {
??????????? dbCreate = “update” // one of ‘create’, ‘create-drop’,'update’
??????????? url = “jdbc:mysql://localhost:3306/gralis?useUnicode=true&characterEncoding=UTF-8″
??????? }
??? }
}
同时在lib文件夹下添加mysql驱动包
?
?
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。