Search in sources :

Example 46 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class Case1 method test_druid.

public void test_druid() throws Exception {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setInitialSize(initialSize);
    dataSource.setMaxActive(maxActive);
    dataSource.setMinIdle(minPoolSize);
    dataSource.setMaxIdle(maxPoolSize);
    dataSource.setPoolPreparedStatements(true);
    dataSource.setDriverClassName(driverClass);
    dataSource.setUrl(jdbcUrl);
    dataSource.setPoolPreparedStatements(true);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    dataSource.setValidationQuery(validationQuery);
    dataSource.setTestOnBorrow(false);
    for (int i = 0; i < loopCount; ++i) {
        p0(dataSource, "druid", threadCount);
    }
    System.out.println();
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 47 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class Case2 method test_0.

public void test_0() throws Exception {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setInitialSize(initialSize);
    dataSource.setMaxActive(maxActive);
    dataSource.setMinIdle(minPoolSize);
    dataSource.setMaxIdle(maxPoolSize);
    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 < executeCount; ++i) {
        p0(dataSource, "druid", threadCount);
    }
    System.out.println();
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 48 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class ReuseStatFilterTest method setUp.

protected void setUp() throws Exception {
    dataSourceA = new DruidDataSource();
    dataSourceB = new DruidDataSource();
    dataSourceA.setUrl("jdbc:mock:xxx_A");
    dataSourceB.setUrl("jdbc:mock:xxx_B");
    StatFilter filter = new StatFilter();
    dataSourceA.getProxyFilters().add(filter);
    dataSourceB.getProxyFilters().add(filter);
    dataSourceA.init();
    dataSourceB.init();
}
Also used : StatFilter(com.alibaba.druid.filter.stat.StatFilter) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 49 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class Slf4jFilterTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("slf4j");
    dataSource.setDbType("mysql");
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 50 with DruidDataSource

use of com.alibaba.druid.pool.DruidDataSource in project druid by alibaba.

the class StatFilterAfterResetTest method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat");
    dataSource.init();
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

DruidDataSource (com.alibaba.druid.pool.DruidDataSource)389 SQLException (java.sql.SQLException)56 OracleMockDriver (com.alibaba.druid.test.util.OracleMockDriver)55 OracleExceptionSorter (com.alibaba.druid.pool.vendor.OracleExceptionSorter)50 MockDriver (com.alibaba.druid.mock.MockDriver)48 Connection (java.sql.Connection)36 FilterAdapter (com.alibaba.druid.filter.FilterAdapter)35 Properties (java.util.Properties)34 FilterChain (com.alibaba.druid.filter.FilterChain)33 ResultSet (java.sql.ResultSet)19 ConnectionProxy (com.alibaba.druid.proxy.jdbc.ConnectionProxy)18 MockConnection (com.alibaba.druid.mock.MockConnection)13 ResultSetProxy (com.alibaba.druid.proxy.jdbc.ResultSetProxy)13 Method (java.lang.reflect.Method)11 PreparedStatement (java.sql.PreparedStatement)11 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)10 Field (java.lang.reflect.Field)8 MockResultSet (com.alibaba.druid.mock.MockResultSet)7 TabularData (javax.management.openmbean.TabularData)7 MockCallableStatement (com.alibaba.druid.mock.MockCallableStatement)6