本文整理汇总了Java中com.alibaba.druid.pool.DruidDataSource.setMaxActive方法的典型用法代码示例。如果您正苦于以下问题:Java DruidDataSource.setMaxActive方法的具体用法?Java DruidDataSource.setMaxActive怎么用?Java DruidDataSource.setMaxActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.setMaxActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* 初始化操作
*
* @param modelName 模块名称
* @param txConfig 配置信息
*/
@Override
public void init(String modelName, TxConfig txConfig) {
dataSource = new DruidDataSource();
final TxDbConfig txDbConfig = txConfig.getTxDbConfig();
dataSource.setUrl(txDbConfig.getUrl());
dataSource.setDriverClassName(txDbConfig.getDriverClassName());
dataSource.setUsername(txDbConfig.getUsername());
dataSource.setPassword(txDbConfig.getPassword());
dataSource.setInitialSize(txDbConfig.getInitialSize());
dataSource.setMaxActive(txDbConfig.getMaxActive());
dataSource.setMinIdle(txDbConfig.getMinIdle());
dataSource.setMaxWait(txDbConfig.getMaxWait());
dataSource.setValidationQuery(txDbConfig.getValidationQuery());
dataSource.setTestOnBorrow(txDbConfig.getTestOnBorrow());
dataSource.setTestOnReturn(txDbConfig.getTestOnReturn());
dataSource.setTestWhileIdle(txDbConfig.getTestWhileIdle());
dataSource.setPoolPreparedStatements(txDbConfig.getPoolPreparedStatements());
dataSource.setMaxPoolPreparedStatementPerConnectionSize(txDbConfig.getMaxPoolPreparedStatementPerConnectionSize());
this.tableName = RepositoryPathUtils.buildDbTableName(modelName);
executeUpdate(SqlHelper.buildCreateTableSql(tableName, txDbConfig.getDriverClassName()));
}
示例2: logDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource logDataSource() throws SQLException, DESException {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(dbConfigProperties.getDriveClass());
druidDataSource.setUrl(dbConfigProperties.getLogUrl());
druidDataSource.setUsername(dbConfigProperties.getLogUsername());
druidDataSource.setPassword(dbConfigProperties.getLogPassword());
druidDataSource.setInitialSize(dbConfigProperties.getInitialSize());
druidDataSource.setMinIdle(dbConfigProperties.getMinIdle());
druidDataSource.setMaxActive(dbConfigProperties.getMaxActive());
druidDataSource.setMaxWait(dbConfigProperties.getMaxWait());
druidDataSource.setTimeBetweenEvictionRunsMillis(dbConfigProperties.getTimeBetweenEvictionRunsMillis());
druidDataSource.setMinEvictableIdleTimeMillis(dbConfigProperties.getMinEvictableIdleTimeMillis());
druidDataSource.setValidationQuery(dbConfigProperties.getValidationQuery());
druidDataSource.setTestWhileIdle(dbConfigProperties.getTestWhileIdle());
druidDataSource.setTestOnBorrow(dbConfigProperties.getTestOnBorrow());
druidDataSource.setTestOnReturn(dbConfigProperties.getTestOnReturn());
druidDataSource.setPoolPreparedStatements(dbConfigProperties.getPoolPreparedStatements());
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(dbConfigProperties.getMaxPoolPreparedStatementPerConnectionSize());
druidDataSource.setFilters(dbConfigProperties.getFilters());
return druidDataSource;
}
示例3: userDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* 使用@Primary注解主数据源
*/
@Bean(name = "userDataSource")
@Primary
public DataSource userDataSource() {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(driverClass);
dataSource.setUrl(url);
dataSource.setUsername(user);
dataSource.setPassword(password);
//configuration
dataSource.setInitialSize(initialSize);
dataSource.setMinIdle(minIdle);
dataSource.setMaxActive(maxActive);
dataSource.setMaxWait(maxWait);
dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
dataSource.setValidationQuery(validationQuery);
dataSource.setTestWhileIdle(testWhileIdle);
dataSource.setTestOnBorrow(testOnBorrow);
dataSource.setTestOnReturn(testOnReturn);
dataSource.setPoolPreparedStatements(poolPreparedStatements);
dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
return dataSource;
}
示例4: createDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
protected DataSource createDataSource() throws SQLException {
// special
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(commonProperties.getUrl());
datasource.setUsername(commonProperties.getUsername());
datasource.setPassword(commonProperties.getPassword());
// common
datasource.setDriverClassName(commonProperties.getDriverClassName());
datasource.setInitialSize(commonProperties.getInitialSize());
datasource.setMinIdle(commonProperties.getMinIdle());
datasource.setMaxActive(commonProperties.getMaxActive());
datasource.setMaxWait(commonProperties.getMaxWait());
datasource
.setTimeBetweenEvictionRunsMillis(commonProperties.getTimeBetweenEvictionRunsMillis());
datasource.setMinEvictableIdleTimeMillis(commonProperties.getMinEvictableIdleTimeMillis());
datasource.setValidationQuery(commonProperties.getValidationQuery());
datasource.setTestWhileIdle(commonProperties.isTestWhileIdle());
datasource.setTestOnBorrow(commonProperties.isTestOnBorrow());
datasource.setTestOnReturn(commonProperties.isTestOnReturn());
datasource.setPoolPreparedStatements(commonProperties.isPoolPreparedStatements());
datasource.setMaxPoolPreparedStatementPerConnectionSize(
commonProperties.getMaxPoolPreparedStatementPerConnectionSize());
datasource.setFilters(commonProperties.getFilters());
datasource.setConnectionProperties(commonProperties.getConnectionProperties());
return datasource;
}
示例5: mafMasterDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean(name = ConfigConstant.NAME_DS_MASTER)
@Primary
@ConfigurationProperties(prefix = ConfigConstant.PREFIX_DS_MASTER)
public DataSource mafMasterDataSource() {
logger.info("----- MAFIA master data source INIT -----");
DruidDataSource ds = new DruidDataSource();
try {
ds.setFilters(env.getProperty("ds.filters"));
} catch (SQLException e) {
logger.warn("Data source set filters ERROR:", e);
}
ds.setMaxActive(NumberUtils.toInt(env.getProperty("ds.maxActive"), 90));
ds.setInitialSize(NumberUtils.toInt(env.getProperty("ds.initialSize"), 10));
ds.setMaxWait(NumberUtils.toInt(env.getProperty("ds.maxWait"), 60000));
ds.setMinIdle(NumberUtils.toInt(env.getProperty("ds.minIdle"), 1));
ds.setTimeBetweenEvictionRunsMillis(NumberUtils.toInt(env.getProperty("ds.timeBetweenEvictionRunsMillis"), 60000));
ds.setMinEvictableIdleTimeMillis(NumberUtils.toInt(env.getProperty("ds.minEvictableIdleTimeMillis"), 300000));
ds.setValidationQuery(env.getProperty("ds.validationQuery"));
ds.setTestWhileIdle(BooleanUtils.toBoolean(env.getProperty("ds.testWhileIdle")));
ds.setTestOnBorrow(BooleanUtils.toBoolean(env.getProperty("ds.testOnBorrow")));
ds.setTestOnReturn(BooleanUtils.toBoolean(env.getProperty("ds.testOnReturn")));
ds.setPoolPreparedStatements(BooleanUtils.toBoolean(env.getProperty("ds.poolPreparedStatements")));
ds.setMaxOpenPreparedStatements(NumberUtils.toInt(env.getProperty("ds.maxOpenPreparedStatements"), 20));
return ds;
}
示例6: dataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(databaseConfig.getUrl());
datasource.setDriverClassName(databaseConfig.getDriverClassName());
datasource.setUsername(databaseConfig.getUsername());
datasource.setPassword(databaseConfig.getPassword());
datasource.setInitialSize(databaseConfig.getInitialSize());
datasource.setMinIdle(databaseConfig.getMinIdle());
datasource.setMaxWait(databaseConfig.getMaxWait());
datasource.setMaxActive(databaseConfig.getMaxActive());
datasource.setMinEvictableIdleTimeMillis(databaseConfig.getMinEvictableIdleTimeMillis());
try {
datasource.setFilters("stat,wall,log4j2");
} catch (SQLException e) {
e.printStackTrace();
}
return datasource;
}
示例7: dataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource dataSource(DruidConfig druidConfig) throws IOException {
DruidDataSource ds = new DruidDataSource();
ds.setDriverClassName("com.mysql.cj.jdbc.Driver");
ds.setUrl(druidConfig.getUrl() + "?" + druidConfig.getOptions());
ds.setUsername(druidConfig.getUser());
ds.setPassword(druidConfig.getPwd());
ds.setInitialSize(druidConfig.getInitialSize());
ds.setMinIdle(druidConfig.getMinIdle());
ds.setMaxActive(druidConfig.getMaxActive());
ds.setMaxWait(druidConfig.getMaxWait());
ds.setTimeBetweenEvictionRunsMillis(druidConfig.getTimeBetweenEvictionRunsMillis());
ds.setMinEvictableIdleTimeMillis(druidConfig.getMinEvictableIdleTimeMillis());
ds.setValidationQuery(druidConfig.getValidationQuery());
ds.setTestWhileIdle(druidConfig.getTestWhileIdle());
ds.setTestOnBorrow(druidConfig.getTestOnBorrow());
ds.setTestOnReturn(druidConfig.getTestOnReturn());
return ds;
}
示例8: createDatasource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* 创建多个数据源来模拟分布式服务环境
* @param properties
* @return
*/
private DataSource createDatasource(EasyTransTestProperties properties) {
DruidDataSource ds = new DruidDataSource();
ds.setUrl(properties.getUrl());
ds.setUsername(properties.getUsername());
ds.setPassword(properties.getPassword());
ds.setMaxActive(10);
ds.setInitialSize(1);
ds.setMinIdle(1);
ds.setPoolPreparedStatements(true);
return ds;
}
示例9: dataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean(initMethod="init",destroyMethod="close")
public DataSource dataSource(){
DruidDataSource ds = new DruidDataSource();
ds.setUrl(config.getUrl());
ds.setUsername(config.getUsername());
ds.setPassword(config.getPassword());
ds.setInitialSize(ds.getInitialSize());
ds.setMinIdle(config.getMinIdle());
ds.setMaxActive(config.getMaxActive());
ds.setMaxWait(config.getMaxWait());
ds.setTimeBetweenEvictionRunsMillis(config.getTimeBetweenEvictionRunsMillis()); // 关闭检测间隔 毫秒
ds.setMinEvictableIdleTimeMillis(config.getMinEvictableIdleTimeMillis()); // 一个连接的最小生存时间
ds.setValidationQuery("SELECT 'x'");
ds.setTestWhileIdle(config.isTestWhileIdle());
ds.setTestOnBorrow(config.isTestOnBorrow());
ds.setTestOnReturn(config.isTestOnReturn());
ds.setPoolPreparedStatements(config.isPoolPreparedStatements());
ds.setMaxPoolPreparedStatementPerConnectionSize(config.getMaxPoolPreparedStatementPerConnectionSize());
ds.setRemoveAbandoned(config.isRemoveAbandoned());
ds.setRemoveAbandonedTimeout(config.getRemoveAbandonedTimeout());
ds.setLogAbandoned(config.isLogAbandoned());
ds.setTimeBetweenLogStatsMillis(config.getTimeBetweenLogStatsMillis());
ds.setPhyTimeoutMillis(config.getPhyTimeoutMillis());
ds.setMaxEvictableIdleTimeMillis(config.getMaxEvictableIdleTimeMillis());
ds.setDbType("mysql");
try {
ds.setFilters("stat,slf4j");
} catch (SQLException e) {
e.printStackTrace();
}
return ds ;
}
示例10: dataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* database configuration
*/
@Bean(initMethod = "init", destroyMethod = "close")
public DataSource dataSource() {
logger.debug("Configuring Datasource");
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(driverClassName);
druidDataSource.setUrl(url);
druidDataSource.setUsername(username);
druidDataSource.setPassword(password);
druidDataSource.setMaxActive(maximumPoolSize);
druidDataSource.setMaxWait(60000);
druidDataSource.setMinIdle(1);
druidDataSource.setValidationQuery("SELECT 1");
druidDataSource.setTestWhileIdle(true);
druidDataSource.setTestOnBorrow(false);
druidDataSource.setTestOnReturn(false);
/**
* configuration exception handling
* */
druidDataSource.setQueryTimeout(15); //sql select max time : 15s
//a connetion must be closed by removeAbandonedTimeout second
druidDataSource.setRemoveAbandoned(true);
druidDataSource.setRemoveAbandonedTimeout(600);
druidDataSource.setLogAbandoned(true);
return druidDataSource;
}
示例11: mysqlDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
public DataSource mysqlDataSource() throws Exception{
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setUrl(this.url);
druidDataSource.setUsername(this.username);
druidDataSource.setPassword(this.password);
druidDataSource.setDriverClassName(this.driverClassName);
druidDataSource.setInitialSize(this.initialSize);
druidDataSource.setMaxActive(this.maxActive);
druidDataSource.setMinIdle(this.minIdle);
druidDataSource.setMaxWait(this.maxWait);
druidDataSource.setTimeBetweenEvictionRunsMillis(this.timeBetweenEvictionRunsMillis);
druidDataSource.setMinEvictableIdleTimeMillis(this.minEvictableIdleTimeMillis);
druidDataSource.setValidationQuery(this.validationQuery);
druidDataSource.setTestWhileIdle(this.testWhileIdle);
druidDataSource.setTestOnBorrow(this.testOnBorrow);
druidDataSource.setTestOnReturn(this.testOnReturn);
druidDataSource.setPoolPreparedStatements(this.poolPreparedStatements);
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(this.maxPoolPreparedStatementPerConnectionSize);
druidDataSource.setFilters(this.filters);
try {
druidDataSource.setFilters("wall,stat");
druidDataSource.setUseGlobalDataSourceStat(true);
druidDataSource.init();
} catch (Exception e) {
throw new RuntimeException("load datasource error, dbProperties is :", e);
}
return druidDataSource;
}
示例12: dataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean
@Primary
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
// configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource
.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
示例13: businessDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean(initMethod = "init", destroyMethod = "close")
@Primary
public DruidDataSource businessDataSource() throws SQLException, DESException {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(dbConfigProperties.getDriveClass());
druidDataSource.setUrl(dbConfigProperties.getBusinessUrl());
druidDataSource.setUsername(dbConfigProperties.getBusinessUsername());
druidDataSource.setPassword(dbConfigProperties.getBusinessPassword());
druidDataSource.setInitialSize(dbConfigProperties.getInitialSize());
druidDataSource.setMinIdle(dbConfigProperties.getMinIdle());
druidDataSource.setMaxActive(dbConfigProperties.getMaxActive());
druidDataSource.setMaxWait(dbConfigProperties.getMaxWait());
druidDataSource.setTimeBetweenEvictionRunsMillis(dbConfigProperties.getTimeBetweenEvictionRunsMillis());
druidDataSource.setMinEvictableIdleTimeMillis(dbConfigProperties.getMinEvictableIdleTimeMillis());
//此项如果为空,下面几个test都不会生效
druidDataSource.setValidationQuery(dbConfigProperties.getValidationQuery());
druidDataSource.setTestWhileIdle(dbConfigProperties.getTestWhileIdle());
druidDataSource.setTestOnBorrow(dbConfigProperties.getTestOnBorrow());
druidDataSource.setTestOnReturn(dbConfigProperties.getTestOnReturn());
//5.5以后的mysql开启,以后的关闭
druidDataSource.setPoolPreparedStatements(dbConfigProperties.getPoolPreparedStatements());
druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(dbConfigProperties.getMaxPoolPreparedStatementPerConnectionSize());
druidDataSource.setFilters(dbConfigProperties.getFilters());
return druidDataSource;
}
示例14: register
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Override
public boolean register() {
if (IsRegistered) {
return HAS_REGISTERED;
}
DruidDataSource ds = new DruidDataSource();
if (!StrUtil.isBlank(name)) {
ds.setName(this.name);
}
ds.setUrl(jdbcURL);
ds.setDriverClassName(jdbcDriver);
ds.setUsername(jdbcUsername);
ds.setPassword(jdbcPassword);
ds.setMinIdle(minIdle);
ds.setMaxActive(maxActive);
ds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
ds.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
ds.setValidationQuery(validationQuery);
ds.setTestWhileIdle(testWhileIdle);
ds.setTestOnBorrow(testOnBorrow);
ds.setTestOnReturn(testOnReturn);
setDataSource(ds);
setIsRegistered(HAS_REGISTERED);
return HAS_REGISTERED;
}
示例15: configDruid
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
private void configDruid(DruidDataSource dataSource, DruidProperties properties) {
dataSource.setUrl(url);
dataSource.setUsername(username);
dataSource.setPassword(password);
if (properties.getInitialSize() > 0) {
dataSource.setInitialSize(properties.getInitialSize());
}
if (properties.getMinIdle() > 0) {
dataSource.setMinIdle(properties.getMinIdle());
}
if (properties.getMaxActive() > 0) {
dataSource.setMaxActive(properties.getMaxActive());
}
if (properties.getMaxWait() > 0 ){
dataSource.setMaxWait(properties.getMaxWait());
}
if (properties.getTimeBetweenEvictionRunsMillis() > 0l){
dataSource.setTimeBetweenEvictionRunsMillis(properties.getTimeBetweenEvictionRunsMillis());
}
if (properties.getMaxPoolPreparedStatementPerConnectionSize() > 0 ){
dataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize());
}
if (properties.getValidationQueryTimeout() > 0 ){
dataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
}
if (properties.getMinEvictableIdleTimeMillis() > 0l){
dataSource.setMinEvictableIdleTimeMillis(properties.getMinEvictableIdleTimeMillis());
}
dataSource.setValidationQuery(properties.getValidationQuery());
dataSource.setTestOnReturn(properties.getTestOnReturn());
dataSource.setTestOnBorrow(properties.isTestOnBorrow());
dataSource.setTestWhileIdle(properties.getTestWhileIdle());
dataSource.setPoolPreparedStatements(properties.getPoolPreparedStatements());
dataSource.setConnectProperties(properties.getConnectionProperties());
try {
dataSource.setFilters(properties.getFilters());
} catch (SQLException e) {
throw new IllegalArgumentException("please check your spring.datasource.druid.filters property.", e);
}
}