grails - multiple database for multiple client but one source

空扰寡人 提交于 2019-12-13 04:33:07

问题


how to use multiple database for multiple client but one source. is there any way to change DataSources.groovy file?


回答1:


Yes, this is possible. Just copy your dataSource at the top of your dataSource file and rename it (eg datasource2). Then copy the dataSource in the development, test and production. Rename the new dataSources with the same name.

Now you are ready to use your dataSource2 with the same way as you use dataSource.

class MySercise {
    def dataSource2

    def myMethod() {
        def sql = new Sql(dataSource2)
    }
}

When using gorm take a look here at Multiple Data Sources Support chapter.



来源:https://stackoverflow.com/questions/18629282/grails-multiple-database-for-multiple-client-but-one-source

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!