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驱动包
?
?