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


Java DruidDataSource.setMaxWait方法代碼示例

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


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

示例1: 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,項目名稱:springbootWeb,代碼行數:23,代碼來源:LogDatabaseConfig.java

示例2: 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());
    druidDataSource.setValidationQuery(dbConfigProperties.getValidationQuery());//此項如果為空,下麵幾個test都不會生效
    druidDataSource.setTestWhileIdle(dbConfigProperties.getTestWhileIdle());
    druidDataSource.setTestOnBorrow(dbConfigProperties.getTestOnBorrow());
    druidDataSource.setTestOnReturn(dbConfigProperties.getTestOnReturn());
    druidDataSource.setPoolPreparedStatements(dbConfigProperties.getPoolPreparedStatements());//5.5以後的mysql開啟,以後的關閉
    druidDataSource.setMaxPoolPreparedStatementPerConnectionSize(dbConfigProperties.getMaxPoolPreparedStatementPerConnectionSize());
    druidDataSource.setFilters(dbConfigProperties.getFilters());
    return druidDataSource;
}
 
開發者ID:DomKing,項目名稱:busi-support,代碼行數:24,代碼來源:BusinessDatabaseConfig.java

示例3: 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

示例4: dataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean
  public DataSource dataSource() {
      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");
} catch (SQLException e) {
	e.printStackTrace();
}
      return datasource;
  }
 
開發者ID:puhaiyang,項目名稱:springBoot-swagger-mybatis-shardbatis,代碼行數:20,代碼來源:DruidDataSourceConfig.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: 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;
}
 
開發者ID:venus-boot,項目名稱:saluki,代碼行數:27,代碼來源:SingleDataSourceConfig.java

示例7: 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

示例8: 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;
}
 
開發者ID:csdbianhua,項目名稱:telemarket-skittle-alley,代碼行數:20,代碼來源:DataConfig.java

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

示例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;
}
 
開發者ID:heikehuan,項目名稱:fly4j,代碼行數:30,代碼來源:DatabaseConfiguration.java

示例11: initialize

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@SuppressWarnings("static-access")
public void initialize() throws SQLException{
       if (this.url == null) {
           throw new SQLException("DBPool could not be created: DB URL cannot be null");
       }

       if (this.driver == null) {
           throw new SQLException("DBPool driver could not be created: DB driver class name cannot be null!");
       }

       if (this.maxConnections < 0) {
           throw new SQLException("DBPool maxConnectins could not be created: Max connections must be greater than zero!");
       }

       datasource = new DruidDataSource();
       try{
           datasource.setDriverClassName(this.driver);
       } catch (Exception e) {
           logger.error("Problem setting driver class name on datasource: {}" + e.getMessage(), e);
       }

       datasource.setUrl(this.url);
       datasource.setUsername(this.user);
       datasource.setPassword(this.password);
       datasource.setMaxActive(this.maxConnections);
       datasource.setMinIdle(1);
       datasource.setMaxWait(0);
       datasource.setMaxPoolPreparedStatementPerConnectionSize(this.DEFAULT_DB_MAX_CACHED_STATEMENTS_PER_CONNECTION);

       if (this.validationQuery != null) {
           datasource.setValidationQuery(this.validationQuery);
           if(!this.validateOnCheckout)
               datasource.setTestOnReturn(true);
           else
               datasource.setTestOnBorrow(true);
           datasource.setValidationQueryTimeout(this.idleConnectionValidationSeconds);
       }
   }
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:39,代碼來源:DruidConnectionProviderManager.java

示例12: 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

示例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: 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

示例15: masterDataSource

import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@Bean(name = "masterDataSource")
@Primary
public DataSource masterDataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setName("master");
    dataSource.setDriverClassName(driverClass);
    dataSource.setUrl(url);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    // 配置初始化大小、最小、最大
    dataSource.setInitialSize(0);
    dataSource.setMinIdle(0);
    dataSource.setMaxActive(10);
    // 配置獲取連接等待超時的時間
    dataSource.setMaxWait(15000);
    // 配置間隔多久才進行一次檢測,檢測需要關閉的空閑連接,單位是毫秒
    dataSource.setTimeBetweenEvictionRunsMillis(60000);
    // 配置一個連接在池中最小生存的時間,一個小時
    dataSource.setMinEvictableIdleTimeMillis(3600000);
    dataSource.setTestWhileIdle(true);
    // 這裏建議配置為TRUE,防止取到的連接不可用
    dataSource.setTestOnBorrow(true);
    dataSource.setTestOnReturn(false);
    // 這裏配置提交方式,默認就是TRUE,可以不用配置
    dataSource.setDefaultAutoCommit(true);
    // 驗證連接有效與否的SQL,不同的數據配置不同
    dataSource.setValidationQuery("SELECT 1");
    return dataSource;
}
 
開發者ID:zheng-zy,項目名稱:springboot-mybatis-druid-mutil-datasource,代碼行數:30,代碼來源:MasterDataSourceConfig.java


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