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 {
6363 ds = DemoApplication .getApplicationContext ().getBean (HikariDataSource .class );
6464 // 另一种方式是 DemoDataSourceConfig 初始化获取到 DataSource 后给静态变量 DATA_SOURCE_HIKARICP 赋值: ds = DemoDataSourceConfig.DATA_SOURCE_HIKARICP.getConnection();
6565 break ;
66- case "DRUID" :
67- case "DRUID-TEST" :
68- case "DRUID-ONLINE" :
66+ default :
6967 Map <String , DruidDataSource > dsMap = DemoApplication .getApplicationContext ().getBeansOfType (DruidDataSource .class );
7068 // 另一种方式是 DemoDataSourceConfig 初始化获取到 DataSource 后给静态变量 DATA_SOURCE_DRUID 赋值: ds = DemoDataSourceConfig.DATA_SOURCE_DRUID.getConnection();
7169 switch (datasource ) {
@@ -74,14 +72,13 @@ public Connection getConnection(SQLConfig config) throws Exception {
7472 case "DRUID-ONLINE" :
7573 ds = dsMap .get ("druidOnlineDataSource" );
7674 break ;
77- default :
75+ case "DRUID" :
7876 ds = dsMap .get ("druidDataSource" );
77+ default :
78+ ds = null ;
7979 break ;
8080 }
8181 break ;
82- default :
83- ds = null ;
84- break ;
8582 }
8683
8784 connectionMap .put (datasource , ds == null ? null : ds .getConnection ());
You can’t perform that action at this time.
0 commit comments