Package com.alibaba.druid.pool

Examples of com.alibaba.druid.pool.DruidDataSource$ActiveConnectionTraceInfo


    private DruidDataSource dataSource;
    private MockDriver      driver;

    protected void setUp() throws Exception {
        driver = new MockDriver();
        dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xxx");
        dataSource.setFilters("stat,trace,log4j,encoding");

    }
View Full Code Here


    protected void tearDown() throws Exception {
        Assert.assertEquals(0, DruidDataSourceStatManager.getInstance().getDataSourceList().size());
    }

    public void test_2() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xxx");

        String sql = "SELECT 1";

        Connection conn = dataSource.getConnection();
        PreparedStatement stmt = conn.prepareStatement(sql);
        ResultSet rs = stmt.executeQuery();
        rs.next();

        Statement mockStmt = stmt.unwrap(Statement.class);
        Assert.assertEquals(false, mockStmt.isClosed());

        conn.close();

        Assert.assertEquals(true, mockStmt.isClosed());

        Assert.assertEquals(true, stmt.isClosed());
        Assert.assertEquals(true, rs.isClosed());

        rs.close();
        stmt.close();

        SQLException error = null;
        try {
            stmt.execute("SELECT 1");
        } catch (SQLException ex) {
            error = ex;
        }
        Assert.assertNotNull(error);

        dataSource.close();
    }
View Full Code Here

        DruidDataSourceStatManager.clear();

        driver = new MockDriver();
        driver.setLogExecuteQueryEnable(false);

        dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xxx");
        dataSource.setDriver(driver);
        dataSource.setInitialSize(1);
        dataSource.setMaxActive(100);
        dataSource.setMaxIdle(100);
View Full Code Here

public class LockFairTest extends TestCase {

    private DruidDataSource dataSource;

    protected void setUp() throws Exception {
        dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xx");
    }
View Full Code Here

    protected void setUp() throws Exception {
        DruidDataSourceStatManager.clear();

        driver = new MockDriver();

        dataSource = new DruidDataSource();
        dataSource.setUrl("jdbc:mock:xxx");
        dataSource.setDriver(driver);
        dataSource.setInitialSize(1);
        dataSource.setMaxActive(2);
        dataSource.setMaxIdle(2);
View Full Code Here

        password = "ccbuauto";
        driverClass = "oracle.jdbc.driver.OracleDriver";
    }

    public void test_0() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();

        dataSource.setMaxActive(maxActive);
        dataSource.setMaxIdle(maxIdle);
        dataSource.setMaxWait(maxWait);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(jdbcUrl);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        dataSource.setValidationQuery(validationQuery);
        dataSource.setTestOnBorrow(testOnBorrow);

        for (int i = 0; i < loopCount; ++i) {
            p0(dataSource, "druid", threadCount);
        }
        System.out.println();
View Full Code Here

        druid();

    }

    public void druid() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();

        dataSource.setInitialSize(initialSize);
        dataSource.setMaxActive(maxActive);
        dataSource.setMaxIdle(maxIdle);
        dataSource.setMinIdle(minIdle);
        dataSource.setMaxWait(maxWait);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setDriverClassName(driverClass);
        dataSource.setUrl(jdbcUrl);
        dataSource.setPoolPreparedStatements(true);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        dataSource.setValidationQuery(validationQuery);
        dataSource.setTestOnBorrow(testOnBorrow);
        dataSource.setTestOnBorrow(testWhileIdle);
        dataSource.setTestOnBorrow(testOnReturn);
        dataSource.setRemoveAbandoned(removeAbandoned);
        dataSource.setRemoveAbandonedTimeout(removeAbandonedTimeout);
        dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
        dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
        dataSource.setNumTestsPerEvictionRun(numTestsPerEvictionRun);

        p0(dataSource, "druid", threadCount);

        long startMillis = System.currentTimeMillis();
        for (int i = 0; i < 1000; ++i) {
View Full Code Here

    public void init(DataSourceProxy dataSourceProxy) {
        if (!(dataSourceProxy instanceof DruidDataSource)) {
            LOG.error("ConfigLoader only support DruidDataSource");
        }

        DruidDataSource dataSource = (DruidDataSource) dataSourceProxy;
        Properties connectinProperties = dataSource.getConnectProperties();

        Properties configFileProperties = loadPropertyFromConfigFile(connectinProperties);

        // 判断是否需要解密,如果需要就进行解密行动
        boolean decrypt = isDecrypt(connectinProperties, configFileProperties);
View Full Code Here

    c3p0.setDriverClass(driver);
    c3p0.setJdbcUrl(url);
    c3p0.setUser(user);
    c3p0.setPassword(password);

    druid = new DruidDataSource();
    druid.setUrl(url);
    druid.setUsername(user);
    druid.setPassword(password);
    druid.setFilters("stat,trace,encoding");
    druid.setDefaultAutoCommit(false);
View Full Code Here

@SuppressWarnings("deprecation")
public class TestTraceFilter extends TestCase {

    public void test_loop() throws Exception {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setFilters("stat,trace");
        dataSource.setUrl("jdbc:mock:");

        JMXUtils.register("com.alibaba.dragoon:type=JdbcTraceManager", JdbcTraceManager.getInstance());

        for (int i = 0; i < 1000; ++i) {
            Connection conn = dataSource.getConnection();
            Statement stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT 1");
            rs.next();
            rs.close();
            stmt.close();
            conn.close();

            Thread.sleep(1000);
        }
        dataSource.close();
    }
View Full Code Here

TOP

Related Classes of com.alibaba.druid.pool.DruidDataSource$ActiveConnectionTraceInfo

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.