Search in sources :

Example 21 with DatabaseType

use of io.shardingjdbc.core.constant.DatabaseType in project sharding-jdbc by shardingjdbc.

the class AbstractDataSourceAdapter method getDatabaseType.

protected DatabaseType getDatabaseType(final Collection<DataSource> dataSources) throws SQLException {
    DatabaseType result = null;
    for (DataSource each : dataSources) {
        DatabaseType databaseType = getDatabaseType(each);
        Preconditions.checkState(null == result || result.equals(databaseType), String.format("Database type inconsistent with '%s' and '%s'", result, databaseType));
        result = databaseType;
    }
    return result;
}
Also used : DatabaseType(io.shardingjdbc.core.constant.DatabaseType) DataSource(javax.sql.DataSource) AbstractUnsupportedOperationDataSource(io.shardingjdbc.core.jdbc.unsupported.AbstractUnsupportedOperationDataSource)

Aggregations

DatabaseType (io.shardingjdbc.core.constant.DatabaseType)21 ShardingDataSource (io.shardingjdbc.core.jdbc.core.datasource.ShardingDataSource)16 Map (java.util.Map)16 Test (org.junit.Test)9 HintShardingValueHelper (io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintShardingValueHelper)8 ShardingRule (io.shardingjdbc.core.rule.ShardingRule)7 ShardingRuleConfiguration (io.shardingjdbc.core.api.config.ShardingRuleConfiguration)6 TableRuleConfiguration (io.shardingjdbc.core.api.config.TableRuleConfiguration)6 AbstractShardingDatabaseOnlyWithHintTest (io.shardingjdbc.core.integrate.type.sharding.hint.base.AbstractShardingDatabaseOnlyWithHintTest)6 SQLShardingRule (io.shardingjdbc.core.integrate.jaxb.SQLShardingRule)5 ShardingConnection (io.shardingjdbc.core.jdbc.core.connection.ShardingConnection)5 Connection (java.sql.Connection)5 PreparedStatement (java.sql.PreparedStatement)5 StandardShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.StandardShardingStrategyConfiguration)4 LinkedList (java.util.LinkedList)4 AbstractRoutingDatabaseOnlyWithHintTest (io.shardingjdbc.core.integrate.type.sharding.hint.base.AbstractRoutingDatabaseOnlyWithHintTest)3 HintDatabaseShardingValueHelper (io.shardingjdbc.core.integrate.type.sharding.hint.helper.HintDatabaseShardingValueHelper)3 ComplexShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.ComplexShardingStrategyConfiguration)2 NoneShardingStrategyConfiguration (io.shardingjdbc.core.api.config.strategy.NoneShardingStrategyConfiguration)2 DatabaseEnvironment (io.shardingjdbc.core.common.env.DatabaseEnvironment)2