Search in sources :

Example 6 with MockDriver

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

the class Bug_for_happyday517 method setUp.

protected void setUp() throws Exception {
    super.setUp();
    originalDataSourceCount = DruidDataSourceStatManager.getInstance().getDataSourceList().size();
    driver = new MockDriver();
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat,trace,log4j,encoding");
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 7 with MockDriver

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

the class Bug_for_happyday517_3 method setUp.

protected void setUp() throws Exception {
    originalDataSourceCount = DruidDataSourceStatManager.getInstance().getDataSourceList().size();
    driver = new MockDriver();
    dataSource = new DruidDataSource();
    dataSource.setDriver(driver);
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat,trace,log4j,encoding");
    dataSource.setDefaultAutoCommit(false);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 8 with MockDriver

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

the class Bug_for_happyday517_2 method setUp.

protected void setUp() throws Exception {
    originalDataSourceCount = DruidDataSourceStatManager.getInstance().getDataSourceList().size();
    final MockPreparedStatement mockStatement = new MockPreparedStatement(null, null) {

        public boolean execute() throws SQLException {
            throw exception;
        }
    };
    driver = new MockDriver() {

        public Connection connect(String url, Properties info) throws SQLException {
            super.connect(url, info);
            return new MockConnection(driver, url, info) {

                public PreparedStatement prepareStatement(String sql) throws SQLException {
                    return mockStatement;
                }
            };
        }
    };
    dataSource = new DruidDataSource();
    dataSource.setDriver(driver);
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setFilters("stat,trace,log4j,encoding");
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) SQLException(java.sql.SQLException) Connection(java.sql.Connection) MockConnection(com.alibaba.druid.mock.MockConnection) MockPreparedStatement(com.alibaba.druid.mock.MockPreparedStatement) PreparedStatement(java.sql.PreparedStatement) MockPreparedStatement(com.alibaba.druid.mock.MockPreparedStatement) Properties(java.util.Properties) MockConnection(com.alibaba.druid.mock.MockConnection) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 9 with MockDriver

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

the class Bug_for_xuershan method setUp.

protected void setUp() throws Exception {
    driver = new MockDriver() {

        public ResultSet createResultSet(MockPreparedStatement stmt) {
            return null;
        }
    };
    dataSource = new DruidDataSource();
    dataSource.setUrl("jdbc:mock:xx");
    dataSource.setDriver(driver);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) ResultSet(java.sql.ResultSet) MockPreparedStatement(com.alibaba.druid.mock.MockPreparedStatement) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Example 10 with MockDriver

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

the class TestPoolPreparedStatement2 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(10);
    dataSource.setTestWhileIdle(true);
    dataSource.setTestOnBorrow(false);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setFilters("stat");
    dataSource.setPoolPreparedStatements(false);
    dataSource.setMaxPoolPreparedStatementPerConnectionSize(20);
// ((StatFilter) dataSource.getProxyFilters().get(0)).setMaxSqlStatCount(100);
}
Also used : MockDriver(com.alibaba.druid.mock.MockDriver) DruidDataSource(com.alibaba.druid.pool.DruidDataSource)

Aggregations

MockDriver (com.alibaba.druid.mock.MockDriver)60 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)49 Connection (java.sql.Connection)17 SQLException (java.sql.SQLException)13 ResultSet (java.sql.ResultSet)10 Properties (java.util.Properties)9 MockConnection (com.alibaba.druid.mock.MockConnection)8 MockStatementBase (com.alibaba.druid.mock.MockStatementBase)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 DruidPooledConnection (com.alibaba.druid.pool.DruidPooledConnection)2