Search in sources :

Example 1 with DatasourceProvider

use of io.mycat.datasource.jdbc.DatasourceProvider in project Mycat2 by MyCATApache.

the class JdbcConnectionManager method createDatasourceProvider.

private static DatasourceProvider createDatasourceProvider(String customerDatasourceProvider) {
    String defaultDatasourceProvider = Optional.ofNullable(customerDatasourceProvider).orElse(DruidDatasourceProvider.class.getName());
    try {
        DatasourceProvider o = (DatasourceProvider) Class.forName(defaultDatasourceProvider).getDeclaredConstructor().newInstance();
        ServerConfig serverConfig = MetaClusterCurrent.exist(ServerConfig.class) ? MetaClusterCurrent.wrapper(ServerConfig.class) : new ServerConfig();
        o.init(serverConfig);
        return o;
    } catch (Exception e) {
        throw new MycatException("can not load datasourceProvider:{}", customerDatasourceProvider);
    }
}
Also used : DruidDatasourceProvider(io.mycat.datasource.jdbc.DruidDatasourceProvider) DruidDatasourceProvider(io.mycat.datasource.jdbc.DruidDatasourceProvider) DatasourceProvider(io.mycat.datasource.jdbc.DatasourceProvider) ServerConfig(io.mycat.config.ServerConfig) MycatException(io.mycat.MycatException) MycatException(io.mycat.MycatException) SQLException(java.sql.SQLException)

Aggregations

MycatException (io.mycat.MycatException)1 ServerConfig (io.mycat.config.ServerConfig)1 DatasourceProvider (io.mycat.datasource.jdbc.DatasourceProvider)1 DruidDatasourceProvider (io.mycat.datasource.jdbc.DruidDatasourceProvider)1 SQLException (java.sql.SQLException)1