• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StatFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.alibaba.druid.filter.stat.StatFilter的典型用法代码示例。如果您正苦于以下问题:Java StatFilter类的具体用法?Java StatFilter怎么用?Java StatFilter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



StatFilter类属于com.alibaba.druid.filter.stat包,在下文中一共展示了StatFilter类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: definitionDataSource

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的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: statFilter

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(prefix = DRUID_STAT_FILTER_PREFIX, name = "enabled", havingValue = "true", matchIfMissing = true)
@ConfigurationProperties(DRUID_STAT_FILTER_PREFIX)
public StatFilter statFilter() {
    log.debug("druid stat-filter init...");
    return new StatFilter();
}
 
开发者ID:drtrang,项目名称:druid-spring-boot,代码行数:8,代码来源:DruidAutoConfiguration.java


示例3: init

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的package包/类
public AutoGen init(String configPath) throws IOException {
    if(configPath == null || configPath.length() == 0){
        configPath = PathKit.getRootClassPath() + "/defaultRule.json" ;
    }
    config = getConfig(configPath) ;
    if(config == null){
        throw new NullPointerException("No Config.");
    }
    JSONObject dataSourceConfig = config.getJSONObject("dataSource") ;
    dp = new DruidPlugin(
            dataSourceConfig.getString("url"),
            dataSourceConfig.getString("user"),
            dataSourceConfig.getString("pwd")
    );
    dp.addFilter(new StatFilter());
    WallFilter wall = new WallFilter();
    wall.setDbType("mysql");
    WallConfig wallConfig = new WallConfig();
    wallConfig.setFunctionCheck(false);
    wallConfig.setCreateTableAllow(true);
    wallConfig.setCommentAllow(true);
    wallConfig.setMultiStatementAllow(true);
    wall.setConfig(wallConfig);
    dp.addFilter(wall);
    arp = new ActiveRecordPlugin(dp);
    arp.setContainerFactory(new CaseInsensitiveContainerFactory(true));// 大小写不敏感
    arp.setDialect(new MysqlDialect());
    dp.start();
    arp.start();
    resourceLoader = new FileResourceLoader(config.getString("baseTemplatePath"),"utf-8");
    cfg = Configuration.defaultConfiguration();
    gt = new GroupTemplate(resourceLoader, cfg);
    System.out.println("-- init success .");
    return this ;
}
 
开发者ID:devilyaos,项目名称:AutoGenerate,代码行数:36,代码来源:AutoGen.java


示例4: buildDruidDataSource

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的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


示例5: initialize

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的package包/类
@Override
public void initialize() throws SQLException {
    Prop prop = PropKit.use(DB_CONFIG);
    druidPlugin = new DruidPlugin(prop.get("jdbcUrl"), prop.get("user"), prop.get("password"));

    // StatFilter提供JDBC层的统计信息
    druidPlugin.addFilter(new StatFilter());
    // WallFilter的功能是防御SQL注入攻击
    WallFilter wallFilter = new WallFilter();
    wallFilter.setDbType("mysql");
    druidPlugin.addFilter(wallFilter);
    druidPlugin.start();
}
 
开发者ID:gumutianqi,项目名称:jfinal-plus,代码行数:14,代码来源:QuartzConnectionProvider.java


示例6: getDruidPlugin

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的package包/类
/**
 * DruidPlugin
 * @param prop : property
 * @return
 */
private DruidEncryptPlugin getDruidPlugin(String ds) {
	this.loadPropertyFile();
	String url = this.getProperty(String.format("db.%s.url", ds));
	url = String.format(URL_TEMPLATE, ds, url);
	String endsWith = "?characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull";
	if (!url.endsWith(endsWith)) {
		url += endsWith;
	}
	DruidEncryptPlugin dp = new DruidEncryptPlugin(url,
			this.getProperty(String.format(USER_TEMPLATE, ds)),
			this.getProperty(String.format(PASSWORD_TEMPLATE, ds)));
	dp.setInitialSize(this.getPropertyToInt(String.format(INITSIZE_TEMPLATE, ds)));
	dp.setMaxActive(this.getPropertyToInt(String.format(MAXSIZE_TEMPLATE, ds)));
	dp.addFilter(new StatFilter());
	WallFilter wall = new WallFilter();
	wall.setDbType(ds);
	dp.addFilter(wall);
	
	if (this.geRuned) {
		dp.start();
		BaseModelGeneratorExt baseGe = new BaseModelGeneratorExt(this.getBaseModelPackage(), this.getBaseModelOutDir());
		baseGe.setGenerateTableNameInModel(this.getGeTableNameInModel());
		baseGe.setGenerateTableColumnNameInModel(this.getGeTableColumnName());
		ModelGenerator modelGe = new ModelGenerator(this.getModelPackage(), this.getBaseModelPackage(), this.getModelOutDir());
		modelGe.setGenerateDaoInModel(this.getGeDaoInModel());
		Generator ge = new Generator(dp.getDataSource(), baseGe, modelGe);
		MappingKitGeneratorExt mappingKitGe = new MappingKitGeneratorExt(this.getModelPackage(), this.getModelOutDir());
		if (!JFinalConfigExt.DEFAULT_MAPPINGKIT_CLASS_NAME.equals(this.getMappingKitClassName())) {
			mappingKitGe.setMappingKitClassName(this.getMappingKitClassName());
		}
		mappingKitGe.setGenerateMappingArpKit(this.getGeMappingArpKit());
		mappingKitGe.setGenerateTableMapping(this.getGeTableMapping());
		ge.setMappingKitGenerator(mappingKitGe);
		ge.setGenerateDataDictionary(this.getGeDictionary());
		ge.generate();
	}
	
	return dp;
}
 
开发者ID:OpeningO,项目名称:JFinal-ext2,代码行数:45,代码来源:JFinalConfigExt.java


示例7: statFilter

import com.alibaba.druid.filter.stat.StatFilter; //导入依赖的package包/类
@Bean
@ConfigurationProperties(prefix = "spring.datasource.druid.stat-filter")
public Filter statFilter() {
    return new StatFilter();
}
 
开发者ID:hualiang0537,项目名称:spring-boot-web-blank,代码行数:6,代码来源:SpringConfigDataSource.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JobInfo类代码示例发布时间:2022-05-22
下一篇:
Java DrillBuf类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap