Search in sources :

Example 51 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class DruidDataSourceTest_oracle_error method setUp.

protected void setUp() throws Exception {
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setTestOnBorrow(false);
    dataSource.setFilters("stat");
    dataSource.setDbType("oracle");
    dataSource.setDriver(new MockDriver() {

        @Override
        public int getMajorVersion() {
            return 9;
        }
    });
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 52 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class ConnectionTest3 method setUp.

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);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat,trace");
    JdbcStatContext context = new JdbcStatContext();
    context.setTraceEnable(true);
    JdbcStatManager.getInstance().setStatContext(context);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) JdbcStatContext(com.alibaba.druid.stat.JdbcStatContext)

Example 53 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class ConnectionTest4 method setUp.

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);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat,trace");
    dataSource.setPoolPreparedStatements(true);
    JdbcStatContext context = new JdbcStatContext();
    context.setTraceEnable(true);
    JdbcStatManager.getInstance().setStatContext(context);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) JdbcStatContext(com.alibaba.druid.stat.JdbcStatContext)

Example 54 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class ConnectionTest method setUp.

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);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat");
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 55 with MockDriver

use of com.alibaba.druid.mock.MockDriver in project druid by alibaba.

the class ConnectionTest2 method setUp.

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);
    dataSource.setMinIdle(1);
    // 300 / 10
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000);
    // 180 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat");
    dataSource.setPoolPreparedStatements(true);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

MockDriver (com.alibaba.druid.mock.MockDriver)58 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)48 Connection (java.sql.Connection)15 SQLException (java.sql.SQLException)11 ResultSet (java.sql.ResultSet)10 MockConnection (com.alibaba.druid.mock.MockConnection)8 MockStatementBase (com.alibaba.druid.mock.MockStatementBase)7 Properties (java.util.Properties)7 MockPreparedStatement (com.alibaba.druid.mock.MockPreparedStatement)5 DataSourceProxyConfig (com.alibaba.druid.proxy.jdbc.DataSourceProxyConfig)5 DataSourceProxyImpl (com.alibaba.druid.proxy.jdbc.DataSourceProxyImpl)5 JdbcStatContext (com.alibaba.druid.stat.JdbcStatContext)5 Log4jFilter (com.alibaba.druid.filter.logging.Log4jFilter)4 CommonsLogFilter (com.alibaba.druid.filter.logging.CommonsLogFilter)3 MockResultSet (com.alibaba.druid.mock.MockResultSet)3 MockStatement (com.alibaba.druid.mock.MockStatement)3 Statement (java.sql.Statement)3 ObjectName (javax.management.ObjectName)3 StatFilter (com.alibaba.druid.filter.stat.StatFilter)2 NullExceptionSorter (com.alibaba.druid.pool.vendor.NullExceptionSorter)2