本文整理汇总了Java中com.alibaba.druid.pool.DruidDataSource.setProxyFilters方法的典型用法代码示例。如果您正苦于以下问题:Java DruidDataSource.setProxyFilters方法的具体用法?Java DruidDataSource.setProxyFilters怎么用?Java DruidDataSource.setProxyFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alibaba.druid.pool.DruidDataSource
的用法示例。
在下文中一共展示了DruidDataSource.setProxyFilters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: definitionDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
@Bean
public DataSource definitionDataSource() throws Exception {
StatFilter statFilter = new StatFilter();
Properties config = new Properties();
config.setProperty("url", dataSourceProperties.getUrl());
config.setProperty("username", dataSourceProperties.getUsername());
config.setProperty("password", dataSourceProperties.getPassword());
config.setProperty("driverClassName", dataSourceProperties.getDriverClassName());
config.setProperty("filters", "slf4j");
DruidDataSource dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(config);
dataSource.setProxyFilters(Collections.singletonList(statFilter));
return dataSource;
}
示例2: buildDruidDataSource
import com.alibaba.druid.pool.DruidDataSource; //导入方法依赖的package包/类
/**
* 创建数据源,有前缀
*
* @param dataSourceMap
* @param prefix
* @return
* @throws SQLException
*/
private DruidDataSource buildDruidDataSource(Map<String, Object> dataSourceMap, String prefix) throws SQLException {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setName(MapUtils.getString(dataSourceMap, prefix + "name"));
dataSource.setDriverClassName(MapUtils.getString(dataSourceMap, prefix + "driverClass"));
dataSource.setUrl(MapUtils.getString(dataSourceMap, prefix + "url"));
dataSource.setUsername(MapUtils.getString(dataSourceMap, prefix + "username"));
dataSource.setPassword(MapUtils.getString(dataSourceMap, prefix + "password"));
// 配置过滤器
WallFilter wallFilter = new WallFilter();
StatFilter statFilter = new StatFilter();
statFilter.setSlowSqlMillis(5000);
statFilter.setLogSlowSql(true);
statFilter.setMergeSql(true);
Slf4jLogFilter slf4jLogFilter = new Slf4jLogFilter();
slf4jLogFilter.setDataSourceLogEnabled(false);
slf4jLogFilter.setConnectionLogEnabled(false);
slf4jLogFilter.setConnectionLogErrorEnabled(true);
slf4jLogFilter.setResultSetLogEnabled(false);
slf4jLogFilter.setResultSetLogErrorEnabled(true);
slf4jLogFilter.setStatementLogEnabled(false);
slf4jLogFilter.setStatementExecutableSqlLogEnable(true);
slf4jLogFilter.setStatementSqlFormatOption(new SQLUtils.FormatOption(false, false));
List filterList = new ArrayList();
filterList.add(wallFilter);
filterList.add(statFilter);
filterList.add(slf4jLogFilter);
dataSource.setProxyFilters(filterList);
return dataSource;
}
示例3: 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
if(initialSize != null) {
datasource.setInitialSize(initialSize);
}
if(minIdle != null) {
datasource.setMinIdle(minIdle);
}
if(maxActive != null) {
datasource.setMaxActive(maxActive);
}
if(maxWait != null) {
datasource.setMaxWait(maxWait);
}
if(timeBetweenEvictionRunsMillis != null) {
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
}
if(minEvictableIdleTimeMillis != null) {
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
}
if(validationQuery!=null) {
datasource.setValidationQuery(validationQuery);
}
if(testWhileIdle != null) {
datasource.setTestWhileIdle(testWhileIdle);
}
if(testOnBorrow != null) {
datasource.setTestOnBorrow(testOnBorrow);
}
if(testOnReturn != null) {
datasource.setTestOnReturn(testOnReturn);
}
if(poolPreparedStatements != null) {
datasource.setPoolPreparedStatements(poolPreparedStatements);
}
if(maxPoolPreparedStatementPerConnectionSize != null) {
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
}
if(connectionProperties != null) {
datasource.setConnectionProperties(connectionProperties);
}
List<Filter> filters = new ArrayList<>();
filters.add(statFilter());
filters.add(wallFilter());
datasource.setProxyFilters(filters);
return datasource;
}