alibaba / druid

阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
https://github.com/alibaba/druid/wiki
Apache License 2.0
27.9k stars 8.57k forks source link

druid-spring-boot-starter 1.1.10 数据库连接错误无法进入catch #3522

Open yzt7805882 opened 4 years ago

yzt7805882 commented 4 years ago

druid 1.1.6对应springboot 1.7.9版本 当数据库ip错误 是可以进入catch druid 1.1.10对应springboot 2.1.3版本 当数据库ip错误 在控制台报错java.sql.SQLException: The Network Adapter could not establish the connection 不断重复报错,然而永远不会进入catch模块 代码如下

try{
            DynamicDataSourceContextHolder.set(DataSourceKey.DB_MASTER);
            List<TXxfbTzggxx> queryData = new ArrayList();
            queryData = tXxfbTzggxxMapper.selectInfoTitle();
        }
        catch(Exception e){
            DynamicDataSourceContextHolder.set(DataSourceKey.DB_OTHER);

        }
yzt7805882 commented 4 years ago

我用druid做多数据源切换,在1.1.6版本当数据库连接失败,会进入catch,可以在catch块切换数据源,然而1.1.10版本以后都不会进入catch,1.1.20也试过 不行,请问是哪里出了问题