Search in sources :

Example 1 with CannotFindDataSourceException

use of com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException in project dynamic-datasource-spring-boot-starter by baomidou.

the class DynamicRoutingDataSource method determinePrimaryDataSource.

private DataSource determinePrimaryDataSource() {
    log.debug("dynamic-datasource switch to the primary datasource");
    DataSource dataSource = dataSourceMap.get(primary);
    if (dataSource != null) {
        return dataSource;
    }
    GroupDataSource groupDataSource = groupDataSources.get(primary);
    if (groupDataSource != null) {
        return groupDataSource.determineDataSource();
    }
    throw new CannotFindDataSourceException("dynamic-datasource can not find primary datasource");
}
Also used : GroupDataSource(com.baomidou.dynamic.datasource.ds.GroupDataSource) CannotFindDataSourceException(com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException) GroupDataSource(com.baomidou.dynamic.datasource.ds.GroupDataSource) ItemDataSource(com.baomidou.dynamic.datasource.ds.ItemDataSource) P6DataSource(com.p6spy.engine.spy.P6DataSource) DataSource(javax.sql.DataSource) AbstractRoutingDataSource(com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource)

Aggregations

AbstractRoutingDataSource (com.baomidou.dynamic.datasource.ds.AbstractRoutingDataSource)1 GroupDataSource (com.baomidou.dynamic.datasource.ds.GroupDataSource)1 ItemDataSource (com.baomidou.dynamic.datasource.ds.ItemDataSource)1 CannotFindDataSourceException (com.baomidou.dynamic.datasource.exception.CannotFindDataSourceException)1 P6DataSource (com.p6spy.engine.spy.P6DataSource)1 DataSource (javax.sql.DataSource)1