加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

Grails多数据源

发布时间:2020-12-14 16:46:46 所属栏目:大数据 来源:网络整理
导读:dataSource { pooled = true driverClassName = "oracle.jdbc.driver.OracleDriver" dialect = org.hibernate.dialect.Oracle10gDialect } hibernate { cache.use_second_level_cache = true cache.use_query_cache = false cache.region.factory_class = 'n
dataSource { pooled = true driverClassName = "oracle.jdbc.driver.OracleDriver" dialect = org.hibernate.dialect.Oracle10gDialect } 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','' // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" url = "jdbc:oracle:thin:@192.168.1.219:1521:sue" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@"******":1521:rcjl" username = ""******"" password = "******" // ? ? ? ? ? ?logSql = true } dataSource_lookup { dbCreate = "update" // one of 'create','' // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" url = "jdbc:oracle:thin:@192.168.1.219:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@"******":1521:rcjl" username = ""******"" password = ""******"" // ? ? ? ? ? ?logSql = true } } test { dataSource { dbCreate = "update" url = "jdbc:oracle:thin:@192.168.1.219:1521:sue" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" username = ""******"" password = ""******"" } dataSource_lookup { dbCreate = "update" url = "jdbc:oracle:thin:@192.168.1.219:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" username = ""******"" password = ""******"" } } production { dataSource { dbCreate = "update" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@192.168.1.219:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@"******":1521:rcjl" url = "jdbc:oracle:thin:@localhost:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" pooled = true // ? ? ? ? ? ?username = "scott" username = ""******"" password = ""******"" dialect = org.hibernate.dialect.Oracle10gDialect properties { maxActive = -1 minEvictableIdleTimeMillis=1800000 timeBetweenEvictionRunsMillis=1800000 numTestsPerEvictionRun=3 testOnBorrow=true testWhileIdle=true testOnReturn=true // ? ? ? ? ? ? ? ?validationQuery="SELECT 1" validationQuery="select 1 from dual" } } dataSource_lookup { dbCreate = "update" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@192.168.1.219:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@"******":1521:rcjl" url = "jdbc:oracle:thin:@localhost:1521:rcjl" // ? ? ? ? ? ?url = "jdbc:oracle:thin:@localhost:1521:rcjl" pooled = true // ? ? ? ? ? ?username = "scott" username = ""******"" password = ""******"" dialect = org.hibernate.dialect.Oracle10gDialect properties { maxActive = -1 minEvictableIdleTimeMillis=1800000 timeBetweenEvictionRunsMillis=1800000 numTestsPerEvictionRun=3 testOnBorrow=true testWhileIdle=true testOnReturn=true // ? ? ? ? ? ? ? ?validationQuery="SELECT 1" validationQuery="select 1 from dual" } } } } 在按制器或服务中直接定义就可以用 import groovy.sql.Sql class TestController { def dataSource_lookup def index() {} def testname(){ ? ? ? def sql=new Sql(dataSource_lookup) def a=sql.rows("select * from T_BASE where sf_id='650203199109142128'") } } 在域类中 class ZipCode { ? ?String code ? ?static mapping = { ? ? ? datasource 'lookup' ? ?} } class ZipCode { ? ?String code ? ?static mapping = { ? ? ? datasources(['lookup','DEFAULT']) ? ?} } class ZipCode { ? ?String code ? ?static mapping = { ? ? ? datasource 'ALL' ? ?} } class ZipCode { ? ?String code ? ?static mapping = { ? ? ? datasources(['lookup','auditing']) ? ?} } def zipCode = ZipCode.auditing.get(42) … zipCode.auditing.save()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读