Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Grails获取可用数据源的列表_Grails_Gorm_Grails 2.0 - Fatal编程技术网

Grails获取可用数据源的列表

Grails获取可用数据源的列表,grails,gorm,grails-2.0,Grails,Gorm,Grails 2.0,在grails中(或使用hibernate方法)有没有办法获取可用的数据源的列表 假设我的配置中有: dataSource { dbCreate = "update" url = "jdbc:h2:mem:testDb;MVCC=TRUE" } dataSource_ALT { dbCreate = "update" url = "jdbc:h2:mem:altDb;MVCC=TRUE" } 我如何在运行时知道我拥有这些数据源(并可能切换它们) 我专门使用了Gra

在grails中(或使用hibernate方法)有没有办法获取可用的
数据源的列表

假设我的配置中有:

dataSource {
    dbCreate = "update"
    url = "jdbc:h2:mem:testDb;MVCC=TRUE"
}

dataSource_ALT {
   dbCreate = "update"
   url = "jdbc:h2:mem:altDb;MVCC=TRUE"
}
我如何在运行时知道我拥有这些数据源(并可能切换它们)


我专门使用了
Grails2.4.3

这有帮助吗?注入@Autowired HibernateDatastore HibernateDatastore并访问HibernateDatastore.connectionSources.getProperties().get(“allConnectionSources”)我还使用了grailsApplication.config.getProperty(“dataSources.alt.url”,String)若要获取对当前数据源配置的访问权。@JasonHeithoff我收到以下错误:没有这样的属性:类的connectionSources:org.codehaus.groovy.grails.orm.hibernate.hibernatedatast请尝试此导入:org.codehaus.groovy.grails.orm.hibernate。HibernateDatastore@JasonHeithoff在我的错误中,那是完全相同的类。