File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/java/apijson/demo Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -63,9 +63,7 @@ public Connection getConnection(SQLConfig config) throws Exception {
63
63
ds = DemoApplication .getApplicationContext ().getBean (HikariDataSource .class );
64
64
// 另一种方式是 DemoDataSourceConfig 初始化获取到 DataSource 后给静态变量 DATA_SOURCE_HIKARICP 赋值: ds = DemoDataSourceConfig.DATA_SOURCE_HIKARICP.getConnection();
65
65
break ;
66
- case "DRUID" :
67
- case "DRUID-TEST" :
68
- case "DRUID-ONLINE" :
66
+ default :
69
67
Map <String , DruidDataSource > dsMap = DemoApplication .getApplicationContext ().getBeansOfType (DruidDataSource .class );
70
68
// 另一种方式是 DemoDataSourceConfig 初始化获取到 DataSource 后给静态变量 DATA_SOURCE_DRUID 赋值: ds = DemoDataSourceConfig.DATA_SOURCE_DRUID.getConnection();
71
69
switch (datasource ) {
@@ -74,14 +72,13 @@ public Connection getConnection(SQLConfig config) throws Exception {
74
72
case "DRUID-ONLINE" :
75
73
ds = dsMap .get ("druidOnlineDataSource" );
76
74
break ;
77
- default :
75
+ case "DRUID" :
78
76
ds = dsMap .get ("druidDataSource" );
77
+ default :
78
+ ds = null ;
79
79
break ;
80
80
}
81
81
break ;
82
- default :
83
- ds = null ;
84
- break ;
85
82
}
86
83
87
84
connectionMap .put (datasource , ds == null ? null : ds .getConnection ());
You can’t perform that action at this time.
0 commit comments