| | |
| | | druidDataSource.setUsername(dbe.getUserName()); |
| | | druidDataSource.setPassword(dbe.getPassWord()); |
| | | // 初始化时建立物理连接的个数 |
| | | druidDataSource.setInitialSize(getProperty("data.system.oracle.connection-pool.initial-size", 10)); |
| | | druidDataSource.setInitialSize(getProperty("data.system.oracle.connection-pool.initial-size", 20)); |
| | | // 最大活动连接数 |
| | | druidDataSource.setMaxActive(getProperty("data.system.oracle.connection-pool.max-active", 100)); |
| | | // 最小空闲连接数 |
| | | druidDataSource.setMinIdle(getProperty("data.system.oracle.connection-pool.min-idle", 20)); |
| | | druidDataSource.setMinIdle(getProperty("data.system.oracle.connection-pool.min-idle", 30)); |
| | | // 校验查询语句 |
| | | druidDataSource.setValidationQuery(dbe.getDataBaseType().getValidationQuery()); |
| | | // 当连接空闲时是否测试连接有效性 |
| | | druidDataSource.setTestWhileIdle(true); |
| | | // 两次空闲连接清除之间的时间间隔 |
| | | druidDataSource.setTimeBetweenEvictionRunsMillis(60000); |
| | | druidDataSource.setMaxWait(60 * 1000); |
| | | // 两次空闲连接清除之间的时间间隔 12小时 |
| | | druidDataSource.setTimeBetweenEvictionRunsMillis(43200000L); |
| | | druidDataSource.setMaxWait(60000L); |
| | | druidDataSource.setPoolPreparedStatements(true); |
| | | druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(100); |
| | | druidDataSource.setRemoveAbandoned(true); |
| | | //半小时强制归还连接 |
| | | druidDataSource.setRemoveAbandonedTimeout(60 * 30); |
| | | DB_DRUID_DATA_SOURCE_MAP.put(ArrayUtil.join(params, ","), druidDataSource); |
| | | } |
| | | try { |
| | | //获获取连接 |
| | | Connection connection = druidDataSource.getConnection(); |
| | |
| | | log.error("获取链接失败", e); |
| | | log.error(url); |
| | | throw new BaseException(ErrorCode.GET_CONNECTION_FAIL); |
| | | } |
| | | } |
| | | } |
| | | } |