Package com.alibaba.druid.proxy.jdbc

Examples of com.alibaba.druid.proxy.jdbc.DataSourceProxy


                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }

            DataSourceProxy oldDataSource = proxyDataSources.putIfAbsent(url, newDataSource);
            if (oldDataSource == null) {
                if (config.isJmxOption()) {
                    JMXUtils.register("com.alibaba.druid:type=JdbcStat", JdbcStatManager.getInstance());
                }
            }
View Full Code Here


                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }

            DataSourceProxy oldDataSource = proxyDataSources.putIfAbsent(url, newDataSource);
            if (oldDataSource == null) {
                if (config.isJmxOption()) {
                    JMXUtils.register("com.alibaba.druid:type=JdbcStat", JdbcStatManager.getInstance());
                }
            }
View Full Code Here

        return counter;
    }

    public JdbcSqlStat createSqlStat(StatementProxy statement, String sql) {
        DataSourceProxy dataSource = statement.getConnectionProxy().getDirectDataSource();
        JdbcDataSourceStat dataSourceStat = dataSource.getDataSourceStat();

        JdbcStatContext context = JdbcStatManager.getInstance().getStatContext();
        String contextSql = context != null ? context.getSql() : null;
        if (contextSql != null && contextSql.length() > 0) {
            return dataSourceStat.createSqlStat(contextSql);
        } else {
            String dbType = this.dbType;

            if (dbType == null) {
                dbType = dataSource.getDbType();
            }

            sql = mergeSql(sql, dbType);
            return dataSourceStat.createSqlStat(sql);
        }
View Full Code Here

                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }

            DataSourceProxy oldDataSource = proxyDataSources.putIfAbsent(url, newDataSource);
            if (oldDataSource == null) {
                if (config.isJmxOption()) {
                    JMXUtils.register("com.alibaba.druid:type=JdbcStat", JdbcStatManager.getInstance());
                }
            }
View Full Code Here

        return counter;
    }

    public JdbcSqlStat createSqlStat(StatementProxy statement, String sql) {
        DataSourceProxy dataSource = statement.getConnectionProxy().getDirectDataSource();
        JdbcDataSourceStat dataSourceStat = dataSource.getDataSourceStat();

        JdbcStatContext context = JdbcStatManager.getInstance().getStatContext();
        String contextSql = context != null ? context.getSql() : null;
        if (contextSql != null && contextSql.length() > 0) {
            return dataSourceStat.createSqlStat(contextSql);
        } else {
            String dbType = this.dbType;

            if (dbType == null) {
                dbType = dataSource.getDbType();
            }

            sql = mergeSql(sql, dbType);
            return dataSourceStat.createSqlStat(sql);
        }
View Full Code Here

        Assert.assertEquals(0, JdbcStatManager.getInstance().getSqlList().size());
    }
   
    public void test_filterEventAdapter() throws Exception {
        DataSourceProxyConfig config = new DataSourceProxyConfig();
        DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);

        FilterEventAdapter filter = new FilterEventAdapter() {
        };

        String sql = "SELECT * FROM PATROL";
View Full Code Here

        Assert.assertEquals(0, JdbcStatManager.getInstance().getSqlList().size());
    }
   
    public void test_connection() throws Exception {
        DataSourceProxyConfig config = new DataSourceProxyConfig();
        DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);

        FilterEventAdapter filter = new FilterEventAdapter() {
        };
        filter.init(dataSource);
View Full Code Here

        Assert.assertEquals(0, JdbcStatManager.getInstance().getSqlList().size());
    }
   
    public void test_call() throws Exception {
        DataSourceProxyConfig config = new DataSourceProxyConfig();
        DataSourceProxy dataSource = new DataSourceProxyImpl(null, config);

        FilterEventAdapter filter = new FilterEventAdapter() {
        };
        filter.init(dataSource);
View Full Code Here

        Assert.assertFalse(driverWrapper.acceptsURL("xxx"));
        Assert.assertTrue(driverWrapper.acceptsURL(url_1));

        Connection connection_1 = DriverManager.getConnection(url_1);
        ConnectionProxy connection_wrapper_1 = connection_1.unwrap(ConnectionProxy.class);
        DataSourceProxy dataSource_1 = connection_wrapper_1.getDirectDataSource();
        Assert.assertEquals(1, dataSource_1.getProxyFilters().size());

        {
            Connection connection_2 = DriverManager.getConnection(url_2);
            ConnectionProxy connection_wrapper_2 = connection_2.unwrap(ConnectionProxy.class);
            DataSourceProxy dataSource_2 = connection_wrapper_2.getDirectDataSource();
            Assert.assertEquals(1, dataSource_2.getProxyFilters().size());
        }

        {
            Connection connection_3 = DriverManager.getConnection(url_3);
            ConnectionProxy connection_wrapper_3 = connection_3.unwrap(ConnectionProxy.class);
            DataSourceProxy dataSource_3 = connection_wrapper_3.getDirectDataSource();
            Assert.assertEquals(1, dataSource_3.getProxyFilters().size());
        }

        {
            Connection connection_4 = DriverManager.getConnection(url_4);
            ConnectionProxy connection_wrapper_4 = connection_4.unwrap(ConnectionProxy.class);
            DataSourceProxy dataSource_4 = connection_wrapper_4.getDirectDataSource();
            dataSource_4.getProxyFilters().toString();
            Assert.assertEquals(1, dataSource_4.getProxyFilters().size());
        }
    }
View Full Code Here

                for (Filter filter : config.getFilters()) {
                    filter.init(newDataSource);
                }
            }

            DataSourceProxy oldDataSource = proxyDataSources.putIfAbsent(url, newDataSource);
            if (oldDataSource == null) {
                if (config.isJmxOption()) {
                    JMXUtils.register("com.alibaba.druid:type=JdbcStat", JdbcStatManager.getInstance());
                }
            }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.proxy.jdbc.DataSourceProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.