|
@@ -30,6 +30,7 @@ public class DruidConfig {
|
|
|
private String jdbcUrl2;//ds2数据源
|
|
|
private String jdbcUrl3;
|
|
|
private String jdbcUrl4;
|
|
|
+ private String jdbcUrl5;
|
|
|
private String username1;
|
|
|
private String password1;
|
|
|
private String username2;
|
|
@@ -38,6 +39,8 @@ public class DruidConfig {
|
|
|
private String password3;
|
|
|
private String username4;
|
|
|
private String password4;
|
|
|
+ private String username5;
|
|
|
+ private String password5;
|
|
|
private int maxActive;
|
|
|
private int minIdle;
|
|
|
private int initialSize;
|
|
@@ -150,6 +153,29 @@ public class DruidConfig {
|
|
|
return druidDataSource;
|
|
|
}
|
|
|
|
|
|
+ public DataSource getDs5() {
|
|
|
+ DruidDataSource druidDataSource = new DruidDataSource();
|
|
|
+ druidDataSource.setDriverClassName(driverClassNameOracle);
|
|
|
+ druidDataSource.setUrl(jdbcUrl5);
|
|
|
+ druidDataSource.setUsername(username5);
|
|
|
+ druidDataSource.setPassword(password5);
|
|
|
+ druidDataSource.setMaxActive(maxActive);
|
|
|
+ druidDataSource.setInitialSize(initialSize);
|
|
|
+ druidDataSource.setTimeBetweenConnectErrorMillis(timeBetweenEvictionRunsMillis);
|
|
|
+ druidDataSource.setValidationQuery(validationQuery);
|
|
|
+ druidDataSource.setTestWhileIdle(testWhileIdle);
|
|
|
+ druidDataSource.setTestOnBorrow(testOnBorrow);
|
|
|
+ druidDataSource.setTestOnReturn(testOnReturn);
|
|
|
+ druidDataSource.setPoolPreparedStatements(poolPreparedStatements);
|
|
|
+ druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
|
|
|
+ try {
|
|
|
+ druidDataSource.setFilters(filters);
|
|
|
+ } catch (SQLException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return druidDataSource;
|
|
|
+ }
|
|
|
+
|
|
|
@Bean
|
|
|
public DataSource dynamicDataSource() {
|
|
|
Map<Object, Object> targetDataSources = new HashMap<>();
|
|
@@ -157,10 +183,12 @@ public class DruidConfig {
|
|
|
DataSource ds2 = getDs2();
|
|
|
DataSource ds3 = getDs3();
|
|
|
DataSource ds4 = getDs4();
|
|
|
+ DataSource ds5 = getDs5();
|
|
|
targetDataSources.put("ds1", ds1);
|
|
|
targetDataSources.put("ds2", ds2);
|
|
|
targetDataSources.put("ds3", ds3);
|
|
|
targetDataSources.put("ds4", ds4);
|
|
|
+ targetDataSources.put("ds5", ds5);
|
|
|
DynamicDataSource dynamicDataSource = new DynamicDataSource();
|
|
|
dynamicDataSource.setTargetDataSources(targetDataSources);
|
|
|
dynamicDataSource.setDefaultTargetDataSource(ds1);
|
|
@@ -168,6 +196,7 @@ public class DruidConfig {
|
|
|
DynamicDataSourceContextHolder.dataSourceIds.add("ds2");
|
|
|
DynamicDataSourceContextHolder.dataSourceIds.add("ds3");
|
|
|
DynamicDataSourceContextHolder.dataSourceIds.add("ds4");
|
|
|
+ DynamicDataSourceContextHolder.dataSourceIds.add("ds5");
|
|
|
return dynamicDataSource;
|
|
|
}
|
|
|
|