本文整理匯總了Java中com.alibaba.druid.pool.DruidDataSource.setUseGlobalDataSourceStat方法的典型用法代碼示例。如果您正苦於以下問題:Java DruidDataSource.setUseGlobalDataSourceStat方法的具體用法?Java DruidDataSource.setUseGlobalDataSourceStat怎麽用?Java DruidDataSource.setUseGlobalDataSourceStat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.setUseGlobalDataSourceStat方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clusterDataSource
import com.alibaba.druid.pool.DruidDataSource; //導入方法依賴的package包/類
@ConfigurationProperties(prefix = "spring.datasource.cluster")
@Bean(name = "clusterDataSource")
public DataSource clusterDataSource() {
DruidDataSource dataSource = new DruidDataSource();
try {
dataSource.setFilters("stat,wall,log4j");
dataSource.setUseGlobalDataSourceStat(true);
} catch (SQLException e) {
//
}
return dataSource;
}
示例2: 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;
}
示例3: 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;
}