Java Code Examples for com.alibaba.druid.pool.DruidDataSource#setTimeBetweenConnectErrorMillis()
The following examples show how to use
com.alibaba.druid.pool.DruidDataSource#setTimeBetweenConnectErrorMillis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DruidDataSourceFactory.java From jboot with Apache License 2.0 | 5 votes |
@Override public DataSource createDataSource(DataSourceConfig config) { DruidDataSource druidDataSource = new DruidDataSource(); druidDataSource.setUrl(config.getUrl()); druidDataSource.setUsername(config.getUser()); druidDataSource.setPassword(config.getPassword()); druidDataSource.setDriverClassName(config.getDriverClassName()); druidDataSource.setMaxActive(config.getMaximumPoolSize()); druidDataSource.setMaxWait(config.getMaxWait()); druidDataSource.setTimeBetweenEvictionRunsMillis(config.getTimeBetweenEvictionRunsMillis()); druidDataSource.setMinEvictableIdleTimeMillis(config.getMinEvictableIdleTimeMillis()); druidDataSource.setTimeBetweenConnectErrorMillis(config.getTimeBetweenConnectErrorMillis()); druidDataSource.setValidationQuery(config.getValidationQuery()); druidDataSource.setTestWhileIdle(config.isTestWhileIdle()); druidDataSource.setTestOnBorrow(config.isTestOnBorrow()); druidDataSource.setTestOnReturn(config.isTestOnReturn()); if (config.getMinimumIdle() != null) { druidDataSource.setMinIdle(config.getMinimumIdle()); } if (config.getConnectionInitSql() != null) { druidDataSource.setConnectionInitSqls(Sets.newHashSet(config.getConnectionInitSql())); } try { druidDataSource.setFilters("stat"); } catch (SQLException e) { log.error("DruidDataSourceFactory is error", e); } return druidDataSource; }
Example 2
Source File: MySQLDruidDataSourceConfiguration.java From spring-boot with Apache License 2.0 | 5 votes |
@Bean @Primary public DataSource dataSource() { // 数据库驱动配置信息 DruidDataSource datasource = new DruidDataSource(); datasource.setDbType(properties.getType()); datasource.setUrl(properties.getUrl()); datasource.setUsername(properties.getUsername()); datasource.setPassword(properties.getPassword()); datasource.setDriverClassName(properties.getDriver()); // 数据库连接池配置信息 datasource.setMaxWait(properties.getMaxWait()); // datasource.setInitialSize(properties.getInitialSize()); //配置后, junit将不能执行 datasource.setMinIdle(properties.getMinIdle()); datasource.setMaxActive(properties.getMaxActive()); datasource.setMaxWait(properties.getMaxWait()); datasource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis()); datasource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis()); datasource.setMaxEvictableIdleTimeMillis(properties.getMaxEvictableIdleTimeMillis()); datasource.setRemoveAbandoned(properties.isRemoveAbandoned()); datasource.setRemoveAbandonedTimeoutMillis(properties.getRemoveAbandonedTimeoutMillis()); datasource.setTimeBetweenConnectErrorMillis(properties.getTimeBetweenConnectErrorMillis()); datasource.setValidationQuery(properties.getValidationQuery()); datasource.setTestWhileIdle(properties.isTestWhileIdle()); datasource.setTestOnBorrow(properties.isTestOnBorrow()); datasource.setTestOnReturn(properties.isTestOnReturn()); datasource.setPoolPreparedStatements(properties.isPoolPreparedStatements()); datasource.setMaxOpenPreparedStatements(properties.getMaxOpenPreparedStatements()); datasource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize()); datasource.setLogAbandoned(properties.isLogAbandoned()); try { datasource.setFilters(properties.getFilters()); } catch (SQLException e) { log.error("Druid setting filters exception: " + e.getMessage(), e); } datasource.setConnectionProperties(properties.getConnectionProperties()); log.info("\n*** Initialize MySQL Druid datasource successful." + properties.getUrl()); return datasource; }
Example 3
Source File: DruidProperties.java From spring-boot-starter-dao with Apache License 2.0 | 4 votes |
public DruidDataSource createDataSource() throws SQLException { DruidDataSource dataSource = new DruidDataSource(); dataSource.setUrl(url); dataSource.setUsername(username); dataSource.setPassword(password); dataSource.setDriverClassName(driverClassName); dataSource.setConnectProperties(connectProperties); dataSource.setInitialSize(initialSize); dataSource.setMinIdle(minIdle); dataSource.setMaxActive(maxActive); dataSource.setMaxWait(maxWait); dataSource.setFilters(filters); dataSource.setDefaultAutoCommit(defaultAutoCommit); dataSource.setTimeBetweenConnectErrorMillis(timeBetweenConnectErrorMillis); dataSource.setValidationQuery(validationQuery); dataSource.setValidationQueryTimeout(validationQueryTimeout); dataSource.setTestWhileIdle(testWhileIdle); dataSource.setTestOnBorrow(testOnBorrow); dataSource.setTestOnReturn(testOnReturn); dataSource.setPoolPreparedStatements(poolPreparedStatements); dataSource.setClearFiltersEnable(clearFiltersEnable); dataSource.setDefaultReadOnly(defaultReadOnly); dataSource.setAsyncCloseConnectionEnable(asyncCloseConnectionEnable); dataSource.setConnectionErrorRetryAttempts(connectionErrorRetryAttempts); dataSource.setBreakAfterAcquireFailure(breakAfterAcquireFailure); dataSource.setDupCloseLogEnable(dupCloseLogEnable); dataSource.setEnable(enable); dataSource.setLogAbandoned(logAbandoned); dataSource.setLogDifferentThread(logDifferentThread); dataSource.setLoginTimeout(loginTimeout); dataSource.setAccessToUnderlyingConnectionAllowed(accessToUnderlyingConnectionAllowed); dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize); dataSource.setQueryTimeout(queryTimeout); dataSource.setFailFast(failFast); dataSource.setMaxCreateTaskCount(maxCreateTaskCount); dataSource.setRemoveAbandoned(removeAbandoned); dataSource.setRemoveAbandonedTimeoutMillis(removeAbandonedTimeoutMillis); dataSource.setDefaultTransactionIsolation(defaultTransactionIsolation); dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); dataSource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis); dataSource.setMaxOpenPreparedStatements(maxOpenPreparedStatements); dataSource.setNotFullTimeoutRetryCount(notFullTimeoutRetryCount); dataSource.setTimeBetweenLogStatsMillis(timeBetweenLogStatsMillis); return dataSource; }