////
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
////

GORM supports the notion of multiple data sources where multiple individual SQL `DataSource` instances can be configured and switched between.

=== Configuring Multiple Data Sources

include::configuration.adoc[]

=== Mapping Domain Classes to Data Sources

include::mappingDomainsToDataSources.adoc[]

=== Data Source Namespaces

include::dataSourceNamespaces.adoc[]

[[connectionSources]]
=== The ConnectionSources API

Introduced in GORM 6.0, the link:../api/org/grails/datastore/mapping/core/connections/ConnectionSources.html[ConnectionSources] API allows you to introspect the data sources configured for the application:

[source,groovy]
----
@Autowired
HibernateDatastore hibernateDatastore
...
ConnectionSources<SessionFactory, HibernateConnectionSourceSettings> connectionSources
					= hibernateDatastore.getConnectionSources()

for(ConnectionSource<SessionFactory, HibernateConnectionSourceSettings> connectionSource in connectionSources) {
	println "Name $connectionSource.name"
	SessionFactory sessionFactory = connectionSource.source
}
----
