Grails 项目配置数据连接的配置文件的编写 Grails连接Oracle grails连接Mysql 的配置文件
2014-04-01 11:12 低调的小码农 阅读(584) 评论(0) 编辑 收藏 举报grails连接Oracle的配置如下:
- dataSource {
- // pooled = true
- // driverClassName = "org.h2.Driver"
- // username = "sa"
- // password = ""
- }
- hibernate {
- cache.use_second_level_cache = true
- cache.use_query_cache = false
- cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
- }
- // environment specific settings
- environments {
- development {
- dataSource {
- dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
- driverClassName = "oracle.jdbc.driver.OracleDriver" //首先需要导入Oracle的数据库及驱动包 我使用的是Ojdbc6.jar
- url = "jdbc:oracle:thin:@localhost:1521:orcl" //数据库的Url 地址, localhost:ip地址,1521 端口号,orcl数据库名,创建的数据存储空间
- dialect = "org.hibernate.dialect.Oracle10gDialect" //数据库方言
- username = "zhiren" //用户名
- password = "zhiren" //密码
- logSql = true
- }
- }
- test {
- dataSource {
- dbCreate = "update"
- url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
- }
- }
- production {
- dataSource {
- dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
- driverClassName = "oracle.jdbc.driver.OracleDriver"
- url = "jdbc:oracle:thin:@localhost:1521:orcl"
- dialect = "org.hibernate.dialect.Oracle10gDialect"
- username = "zhiren"
- password = "zhiren"
- logSql = true
- }
- }
- }
grails 连接Mysql 数据库的配置文件
- dataSource { //通用配置
- pooled = true
- driverClassName = 'com.mysql.jdbc.Driver' //连接Mysql的数据库驱动 我使用的是mysql-connector-java-5.1.5-bin.jar
- dialect = org.hibernate.dialect.MySQL5InnoDBDialect //数据库方言
- }
- hibernate {
- cache.use_second_level_cache = true
- cache.use_query_cache = true
- show_sql = false
- cache.provider_class = 'org.hibernate.cache.EhCacheProvider'
- }
- environments {
- development {
- dataSource {
- dbCreate = "create-drop"
- url = 'jdbc:mysql://127.0.1.1/zhiren' //连接数据库库的Url 地址,1127.0.1.1 数据库ip地址,zhiren ,数据库名字 我的没加端口号就可以连接的。正常的是需要加上 端口号:3306
- username = 'root' //用户名
- password = 'root' //密码
- }
- }
- test {
- dataSource {
- url = 'jdbc:hsqldb:mem:testDb'
- }
- }
- production {
- dataSource {
- dbCreate = "create-drop"
- url = 'jdbc:mysql://127.0.1.1/zhiren'
- username = 'root'
- password = 'root'
- }
- }
- }