当前位置: 首页>>代码示例>>Java>>正文


Java DruidDataSource.setProxyFilters方法代码示例

本文整理汇总了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;
}
 
开发者ID:justice-code,项目名称:QiuQiu,代码行数:17,代码来源:ApplicationStart.java

示例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;
}
 
开发者ID:lupindong,项目名称:xq_seckill_microservice,代码行数:41,代码来源:DynamicDataSourceRegister.java

示例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;
}
 
开发者ID:zhaoqicheng,项目名称:renren-fast,代码行数:59,代码来源:DruidConfig.java


注:本文中的com.alibaba.druid.pool.DruidDataSource.setProxyFilters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。