當前位置: 首頁>>代碼示例>>Java>>正文


Java DruidDataSource.setMinEvictableIdleTimeMillis方法代碼示例

本文整理匯總了Java中com.alibaba.druid.pool.DruidDataSource.setMinEvictableIdleTimeMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java DruidDataSource.setMinEvictableIdleTimeMillis方法的具體用法?Java DruidDataSource.setMinEvictableIdleTimeMillis怎麽用?Java DruidDataSource.setMinEvictableIdleTimeMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.alibaba.druid.pool.DruidDataSource的用法示例。


在下文中一共展示了DruidDataSource.setMinEvictableIdleTimeMillis方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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;
}
 
開發者ID:egojit8,項目名稱:easyweb,代碼行數:20,代碼來源:DruidDataSourceConfig.java

示例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;
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:23,代碼來源:LogDatabaseConfig.java

示例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;
}
 
開發者ID:ychaoyang,項目名稱:autotest,代碼行數:27,代碼來源:UserDataSourceConfig.java

示例4: studentDataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "studentDataSource")
public DataSource studentDataSource() {
	DruidDataSource dataSource = new DruidDataSource();
	dataSource.setUrl(studentUrl);
	dataSource.setUsername(studentUser);
	dataSource.setPassword(studentPassword);
	dataSource.setDriverClassName(studentDriverClass);
	//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;
}
 
開發者ID:ychaoyang,項目名稱:autotest,代碼行數:23,代碼來源:StudentDataSourceConfig.java

示例5: dataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
  public DataSource dataSource() {
      System.out.println("注入druid!!!");
      DruidDataSource datasource = new DruidDataSource();
      datasource.setUrl(propertyResolver.getProperty("url"));
      datasource.setDriverClassName(propertyResolver.getProperty("driver-class-name"));
      datasource.setUsername(propertyResolver.getProperty("username"));
      datasource.setPassword(propertyResolver.getProperty("password"));
      datasource.setInitialSize(Integer.valueOf(propertyResolver.getProperty("initial-size")));
      datasource.setMinIdle(Integer.valueOf(propertyResolver.getProperty("min-idle")));
      datasource.setMaxWait(Long.valueOf(propertyResolver.getProperty("max-wait")));
      datasource.setMaxActive(Integer.valueOf(propertyResolver.getProperty("max-active")));
      datasource.setMinEvictableIdleTimeMillis(Long.valueOf(propertyResolver.getProperty("min-evictable-idle-time-millis")));
      try {
	datasource.setFilters("stat,wall,stat,log4j,default");
} catch (SQLException e) {
	e.printStackTrace();
}
      return datasource;
  }
 
開發者ID:RayeWang,項目名稱:easyadmin,代碼行數:21,代碼來源:DruidDataSourceConfig.java

示例6: 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;
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:26,代碼來源:DsMasterConfig.java

示例7: 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 ; 
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:33,代碼來源:DatabaseConfig.java

示例8: 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;
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:28,代碼來源:BusinessDatabaseConfig.java

示例9: dataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(initMethod = "init", destroyMethod = "close")
public DruidDataSource dataSource() throws SQLException {
    if (StringUtils.isEmpty(propertyResolver.getProperty("url"))) {
        System.out.println("Your database connection pool configuration is incorrect!"
                + " Please check your Spring profile, current profiles are:"
                + Arrays.toString(environment.getActiveProfiles()));
        throw new ApplicationContextException(
                "Database connection pool is not configured correctly");
    }
    DruidDataSource druidDataSource = new DruidDataSource();
    druidDataSource.setDriverClassName(propertyResolver.getProperty("driver-class-name"));
    druidDataSource.setUrl(propertyResolver.getProperty("url"));
    druidDataSource.setUsername(propertyResolver.getProperty("username"));
    druidDataSource.setPassword(propertyResolver.getProperty("password"));
    druidDataSource.setInitialSize(Integer.parseInt(propertyResolver.getProperty("initialSize")));
    druidDataSource.setMinIdle(Integer.parseInt(propertyResolver.getProperty("minIdle")));
    druidDataSource.setMaxActive(Integer.parseInt(propertyResolver.getProperty("maxActive")));
    druidDataSource.setMaxWait(Integer.parseInt(propertyResolver.getProperty("maxWait")));
    druidDataSource.setTimeBetweenEvictionRunsMillis(Long.parseLong(propertyResolver.getProperty("timeBetweenEvictionRunsMillis")));
    druidDataSource.setMinEvictableIdleTimeMillis(Long.parseLong(propertyResolver.getProperty("minEvictableIdleTimeMillis")));
    druidDataSource.setValidationQuery(propertyResolver.getProperty("validationQuery"));
    druidDataSource.setTestWhileIdle(Boolean.parseBoolean(propertyResolver.getProperty("testWhileIdle")));
    druidDataSource.setTestOnBorrow(Boolean.parseBoolean(propertyResolver.getProperty("testOnBorrow")));
    druidDataSource.setTestOnReturn(Boolean.parseBoolean(propertyResolver.getProperty("testOnReturn")));
    druidDataSource.setPoolPreparedStatements(Boolean.parseBoolean(propertyResolver.getProperty("poolPreparedStatements")));
    druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(Integer.parseInt(propertyResolver.getProperty("maxPoolPreparedStatementPerConnectionSize")));
    druidDataSource.setFilters(propertyResolver.getProperty("filters"));
    return druidDataSource;
}
 
開發者ID:jmdhappy,項目名稱:xxpay-master,代碼行數:30,代碼來源:DruidDataSourceConfig.java

示例10: start

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public boolean start() {
	ds = new DruidDataSource();
	
	ds.setUrl(url);
	ds.setUsername(username);
	ds.setPassword(password);
	ds.setDriverClassName(driverClass);
	ds.setInitialSize(initialSize);
	ds.setMinIdle(minIdle);
	ds.setMaxActive(maxActive);
	ds.setMaxWait(maxWait);
	ds.setTimeBetweenConnectErrorMillis(timeBetweenConnectErrorMillis);
	ds.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
	ds.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
	
	ds.setValidationQuery(validationQuery);
	ds.setTestWhileIdle(testWhileIdle);
	ds.setTestOnBorrow(testOnBorrow);
	ds.setTestOnReturn(testOnReturn);
	
	ds.setRemoveAbandoned(removeAbandoned);
	ds.setRemoveAbandonedTimeoutMillis(removeAbandonedTimeoutMillis);
	ds.setLogAbandoned(logAbandoned);
	
	//隻要maxPoolPreparedStatementPerConnectionSize>0,poolPreparedStatements就會被自動設定為true,參照druid的源碼
	ds.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
	
	if (StrKit.notBlank(filters))
		try {ds.setFilters(filters);} catch (SQLException e) {throw new RuntimeException(e);}
	
	addFilterList(ds);
	return true;
}
 
開發者ID:WhatAKitty,項目名稱:spark-project,代碼行數:34,代碼來源:DruidConfiguration.java

示例11: 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);
    }
}
 
開發者ID:cuisongliu,項目名稱:druid-boot-starter,代碼行數:41,代碼來源:DruidAutoConfiguration.java

示例12: dataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean     //聲明其為Bean實例
@Primary  //在同樣的DataSource中,首先使用被標注的DataSource
public DataSource dataSource() {
    DruidDataSource datasource = new DruidDataSource();
    datasource.setUrl(url);
    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;
}
 
開發者ID:yanghuijava,項目名稱:elephant,代碼行數:31,代碼來源:DruidConfiguration.java

示例13: dataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean     //聲明其為Bean實例  
public DataSource dataSource(){  
    DruidDataSource datasource = new DruidDataSource();  
    datasource.setUrl(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);  
    datasource.setUseGlobalDataSourceStat(useGlobalDataSourceStat);  
    try {  
        datasource.setFilters(filters);  
    } catch (SQLException e) {  
        System.err.println("druid configuration initialization filter: "+ e);  
    }  
    datasource.setConnectionProperties(connectionProperties);  
    return datasource;  
}
 
開發者ID:ranji1221,項目名稱:lemcloud,代碼行數:31,代碼來源:DruidConfig.java

示例14: 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;
}
 
開發者ID:YupaiTS,項目名稱:docs-manage,代碼行數:29,代碼來源:DruidProperties.java

示例15: init

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
public void init() throws Exception{  
    System.out.println("**************init"); 
    MicroMetaDao dao=MicroMetaDao.getInstance();
    String sql="select * from nh_micro_dbconf";
    List<Map<String,Object>> infoList=dao.queryObjJoinByCondition(sql);
    for(Map<String,Object> row:infoList){
    	String metaKey=(String) row.get("meta_key");
    	String dataSourceClassName=(String) row.get("datasource_classname");
    	String dbUser=(String) row.get("db_user");
    	String dbPassWord=(String) row.get("db_password");
    	if(dbPassWord.startsWith("nhjm-")){
    		String temp=dbPassWord.substring(5);
    		dbPassWord=DESUtil.decrypt(temp);
    	}
    	String dbUrl=(String) row.get("db_url");
    	DruidDataSource ds=new DruidDataSource();
    	ds.setUsername(dbUser);
    	ds.setPassword(dbPassWord);
    	ds.setUrl(dbUrl);
    	ds.setFilters("stat");
    	ds.setMaxActive(10);
    	ds.setInitialSize(1);
    	ds.setMaxWait(60000);
    	ds.setMinIdle(1);
    	ds.setTimeBetweenEvictionRunsMillis(60000);
    	ds.setMinEvictableIdleTimeMillis(60000);
    	ds.setValidationQuery("SELECT 'x'");
    	ds.setTestWhileIdle(true);
    	ds.setTestOnBorrow(false);
    	ds.setTestOnReturn(false);
    	ds.setPoolPreparedStatements(true);
    	ds.setMaxPoolPreparedStatementPerConnectionSize(10);
    	ds.setDriverClassName(dataSourceClassName);
    	ds.init();
    	JdbcTemplate jdbcTemplate=new JdbcTemplate();
    	jdbcTemplate.setDataSource(ds);
    	MicroDbHolder.getDbHolder().put(metaKey, jdbcTemplate);
    }
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:40,代碼來源:MicroDSInit.java


注:本文中的com.alibaba.druid.pool.DruidDataSource.setMinEvictableIdleTimeMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。