Ejemplo n.º 1
0
  public void test_f() throws Exception {
    final DruidDataSource dataSource = new DruidDataSource();
    dataSource.setTimeBetweenConnectErrorMillis(100);

    final long startTime = System.currentTimeMillis();
    final long okTime = startTime + 1000 * 1;

    dataSource.setDriver(
        new MockDriver() {

          @Override
          public Connection connect(String url, Properties info) throws SQLException {
            if (System.currentTimeMillis() < okTime) {
              throw new SQLException();
            }

            return super.connect(url, info);
          }
        });
    dataSource.setUrl("jdbc:mock:");

    dataSource.setMinIdle(0);
    dataSource.setMaxActive(2);
    dataSource.setMaxIdle(2);

    Connection conn = dataSource.getConnection();
    conn.close();

    dataSource.close();
  }
Ejemplo n.º 2
0
  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);
  }
  protected void setUp() throws Exception {
    Assert.assertEquals(0, JdbcStatManager.getInstance().getSqlList().size());

    dataSource = new DruidDataSource();

    dataSource.setExceptionSorter(new OracleExceptionSorter());

    dataSource.setDriver(new OracleMockDriver());
    dataSource.setUrl("jdbc:mock:xxx");
    dataSource.setPoolPreparedStatements(true);
    dataSource.setMaxOpenPreparedStatements(100);
  }
  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);
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000); // 300 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(10); // 180 / 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);
  }
Ejemplo n.º 5
0
  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);
    dataSource.setMinEvictableIdleTimeMillis(300 * 1000); // 300 / 10
    dataSource.setTimeBetweenEvictionRunsMillis(180 * 1000); // 180 / 10
    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);
  }