Search in sources :

Example 1 with StatFilter

use of com.alibaba.druid.filter.stat.StatFilter in project my_curd by qinyou.

the class AppConfig method configPlugin.

@Override
public void configPlugin(Plugins me) {
    DruidPlugin dbPlugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password"));
    // druid 监控
    dbPlugin.addFilter(new StatFilter());
    WallFilter wall = new WallFilter();
    wall.setDbType("mysql");
    dbPlugin.addFilter(wall);
    ActiveRecordPlugin arp = new ActiveRecordPlugin(dbPlugin);
    arp.setShowSql(PropKit.getBoolean("devMode"));
    arp.setDialect(new MysqlDialect());
    MappingKit.mapping(arp);
    me.add(dbPlugin);
    me.add(arp);
}
Also used : WallFilter(com.alibaba.druid.wall.WallFilter) MysqlDialect(com.jfinal.plugin.activerecord.dialect.MysqlDialect) DruidPlugin(com.jfinal.plugin.druid.DruidPlugin) StatFilter(com.alibaba.druid.filter.stat.StatFilter) ActiveRecordPlugin(com.jfinal.plugin.activerecord.ActiveRecordPlugin)

Example 2 with StatFilter

use of com.alibaba.druid.filter.stat.StatFilter in project neweagle-api by apgzs.

the class DruidConfiguration method statFilter.

@Bean
public StatFilter statFilter() {
    StatFilter statFilter = new StatFilter();
    statFilter.setLogSlowSql(true);
    statFilter.setMergeSql(true);
    statFilter.setSlowSqlMillis(1000);
    return statFilter;
}
Also used : WebStatFilter(com.alibaba.druid.support.http.WebStatFilter) StatFilter(com.alibaba.druid.filter.stat.StatFilter) FilterRegistrationBean(org.springframework.boot.web.servlet.FilterRegistrationBean) ServletRegistrationBean(org.springframework.boot.web.servlet.ServletRegistrationBean) Bean(org.springframework.context.annotation.Bean)

Example 3 with StatFilter

use of com.alibaba.druid.filter.stat.StatFilter in project druid by alibaba.

the class SlowSqlMillisTest2 method test_connect.

public void test_connect() throws Exception {
    StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
    Assert.assertEquals(500, filter.getSlowSqlMillis());
}
Also used : StatFilter(com.alibaba.druid.filter.stat.StatFilter)

Example 4 with StatFilter

use of com.alibaba.druid.filter.stat.StatFilter in project druid by alibaba.

the class SlowSqlMillisTest method test_connect.

public void test_connect() throws Exception {
    StatFilter filter = (StatFilter) dataSource.getProxyFilters().get(0);
    Assert.assertEquals(500, filter.getSlowSqlMillis());
}
Also used : StatFilter(com.alibaba.druid.filter.stat.StatFilter)

Example 5 with StatFilter

use of com.alibaba.druid.filter.stat.StatFilter in project druid by alibaba.

the class ResultSetProxyImplTest method test_resultset.

public void test_resultset() throws Exception {
    MockDriver driver = new MockDriver();
    DataSourceProxyConfig config = new DataSourceProxyConfig();
    config.setUrl("");
    config.setRawUrl("jdbc:mock:");
    DataSourceProxyImpl dataSource = new DataSourceProxyImpl(driver, config);
    {
        StatFilter filter = new StatFilter();
        filter.init(dataSource);
        config.getFilters().add(filter);
    }
    {
        Log4jFilter filter = new Log4jFilter();
        filter.init(dataSource);
        config.getFilters().add(filter);
    }
    Connection conn = dataSource.connect(null);
    conn.setClientInfo("name", null);
    Statement stmt = conn.createStatement();
    ResultSetProxy rs = (ResultSetProxy) stmt.executeQuery(sql);
    rs.insertRow();
    rs.refreshRow();
    rs.moveToInsertRow();
    rs.moveToCurrentRow();
    rs.next();
    rs.updateRef(1, null);
    rs.updateArray(1, null);
    rs.updateRowId(1, null);
    rs.updateNString(1, null);
    rs.updateNClob(1, (NClob) null);
    rs.updateNClob(1, (Reader) null);
    rs.updateNClob(1, (Reader) null, 0);
    rs.updateSQLXML(1, null);
    rs.updateNCharacterStream(1, null);
    rs.updateNCharacterStream(1, null, 0);
    rs.getArray("1");
    rs.updateRef("1", null);
    rs.updateArray("1", null);
    rs.updateRowId("1", null);
    rs.updateNString("1", null);
    rs.updateNClob("1", (NClob) null);
    rs.updateNClob("1", (Reader) null);
    rs.updateNClob("1", (Reader) null, 0);
    rs.updateSQLXML("1", null);
    rs.updateNCharacterStream("1", null);
    rs.updateNCharacterStream("1", null, 0);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DataSourceProxyConfig(com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig) DataSourceProxyImpl(com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl) Statement(java.sql.Statement) Log4jFilter(com.alibaba.druid.filter.logging.Log4jFilter) StatFilter(com.alibaba.druid.filter.stat.StatFilter) Connection(java.sql.Connection) ResultSetProxy(com.alibaba.druid.proxy.jdbc.ResultSetProxy)

Aggregations

StatFilter (com.alibaba.druid.filter.stat.StatFilter)21 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)4 Connection (java.sql.Connection)4 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)3 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)3 MockDriver (com.alibaba.druid.mock.MockDriver)2 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)2 WebStatFilter (com.alibaba.druid.support.http.WebStatFilter)2 WallFilter (com.alibaba.druid.wall.WallFilter)2 Statement (java.sql.Statement)2 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)2 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)2 Bean (org.springframework.context.annotation.Bean)2 Filter (com.alibaba.druid.filter.Filter)1 FilterChain (com.alibaba.druid.filter.FilterChain)1 FilterChainImpl (com.alibaba.druid.filter.FilterChainImpl)1 Log4jFilter (com.alibaba.druid.filter.logging.Log4jFilter)1 MergeStatFilter (com.alibaba.druid.filter.stat.MergeStatFilter)1 JdbcDataSourceStat (com.alibaba.druid.stat.JdbcDataSourceStat)1 ActiveRecordPlugin (com.jfinal.plugin.activerecord.ActiveRecordPlugin)1