Examples of BoneCPDataSource


Examples of com.jolbox.bonecp.BoneCPDataSource

        }
        System.out.println();
    }

    public void f_test_2() throws Exception {
        BoneCPDataSource dataSource = new BoneCPDataSource();
        // dataSource.(10);
        // dataSource.setMaxActive(50);
        dataSource.setMinConnectionsPerPartition(minIdle);
        dataSource.setMaxConnectionsPerPartition(maxIdle);

        dataSource.setDriverClass(driverClass);
        dataSource.setJdbcUrl(jdbcUrl);
        // dataSource.setPoolPreparedStatements(true);
        // dataSource.setMaxOpenPreparedStatements(100);
        dataSource.setUsername(user);
        dataSource.setPassword(password);
        dataSource.setConnectionTestStatement(validationQuery);
        dataSource.setPartitionCount(1);

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

Examples of com.jolbox.bonecp.BoneCPDataSource

    public DataSource pool(final String name, final String driver, final Properties properties) {
        // bonecp already have a kind of ObjectRecipe so simply giving it the values
        final Properties props = new Properties();
        props.put("properties", prefixedProps(properties));

        final BoneCPDataSource ds = build(BoneCPDataSource.class, props);
        if (ds.getDriverClass() == null || ds.getDriverClass().isEmpty()) {
            ds.setDriverClass(driver);
        }
        if (ds.getPoolName() == null || ds.getPoolName().isEmpty()) {
            ds.setPoolName(name);
        }
        return ds;
    }
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

   * @param database The database type.
   * @return A high performance connection pool datasource.
   */
  private static DataSource newPooledDataSource(final Environment env,
      final String database) {
    BoneCPDataSource datasource = new BoneCPDataSource();
    datasource.setJdbcUrl(database);
    datasource.setDriverClass(env.getProperty(DB_DRIVER,
        DB_DEFAULT_DRIVER));
    datasource.setUsername(env.getRequiredProperty(DB_USER));
    datasource.setPassword(env.getRequiredProperty(DB_PASSWORD));
    datasource.setIdleConnectionTestPeriod(env.getProperty(
        DB_IDDLE_CONNECTION_TEST_PERIOD, Integer.class,
        DB_DEFAULT_IDDLE_CONNECTION_TEST_PERIOD), TimeUnit.SECONDS);
    datasource.setIdleMaxAge(env.getProperty(DB_IDDLE_MAX_AGE,
        Integer.class, DB_DEFAULT_IDDLE_MAX_AGE), TimeUnit.SECONDS);
    datasource.setMaxConnectionsPerPartition(env.getProperty(
        DB_MAX_CONNECTIONS_PER_PARTITION, Integer.class,
        DB_DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
    datasource.setMinConnectionsPerPartition(env.getProperty(
        DB_MIN_CONNECTIONS_PER_PARTITION, Integer.class,
        DB_DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
    datasource.setPartitionCount(env.getProperty(DB_PARTITION_COUNT,
        Integer.class, DB_DEFAULT_PARTITION_COUNT));
    datasource.setAcquireIncrement(env.getProperty(DB_ACQUIRE_INCREMENT,
        Integer.class, DB_DEFAULT_ACQUIRE_INCREMENT));
    datasource.setStatementsCacheSize(env.getProperty(
        DB_STATEMENTS_CACHE_SIZE, Integer.class,
        DB_DEFAULT_STATEMENTS_CACHE_SIZE));
    logger.info("Creating high performance connection pool: '{}'", database);
    return datasource;
  }
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

    expect(
        env.getProperty(DataSources.DB_STATEMENTS_CACHE_SIZE,
            Integer.class, 20))
        .andReturn(20);

    BoneCPDataSource dataSource =
        PowerMock.createMockAndExpectNew(BoneCPDataSource.class);
    dataSource.setJdbcUrl(database);
    expectLastCall();
    dataSource.setDriverClass(dbDriver);
    expectLastCall();
    dataSource.setUsername(dbUser);
    expectLastCall();
    dataSource.setPassword(dbPass);
    expectLastCall();
    dataSource.setIdleConnectionTestPeriod(14400, TimeUnit.SECONDS);
    expectLastCall();
    dataSource.setIdleMaxAge(3600, TimeUnit.SECONDS);
    expectLastCall();
    dataSource.setMaxConnectionsPerPartition(30);
    expectLastCall();
    dataSource.setMinConnectionsPerPartition(10);
    expectLastCall();
    dataSource.setPartitionCount(3);
    expectLastCall();
    dataSource.setAcquireIncrement(5);
    expectLastCall();
    dataSource.setStatementsCacheSize(20);
    expectLastCall();

    PowerMock.replay(BoneCPDataSource.class);
    replay(env, dataSource);
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

    }
    initDataSource(repo);
  }
 
  protected DataSource initDataSource(ComponentRepository repo) {
    BoneCPDataSource dataSource = new BoneCPDataSource();
    dataSource.setDriverClass(getDriverClass());
    dataSource.setJdbcUrl(getJdbcUrl());
    dataSource.setUsername(getUsername());
    dataSource.setPassword(getPassword());
    dataSource.setPoolName(getPoolName());
    dataSource.setPartitionCount(getPartitionCount());
    dataSource.setAcquireIncrement(getAcquireIncrement());
    dataSource.setMinConnectionsPerPartition(getMinConnectionsPerPartition());
    dataSource.setMaxConnectionsPerPartition(getMaxConnectionsPerPartition());
   
    ComponentInfo info = new ComponentInfo(DataSource.class, getClassifier());
    repo.registerComponent(info, dataSource);
    return dataSource;
  }
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

    // REVIEW jonathan 2013-05-14 -- don't look at this :-)
    if (!(getDbConnector().getDataSource() instanceof BoneCPDataSource)) {
      s_logger.warn("Unable to obtain database management instance. Database objects cannot be inspected or modified, and may be missing or out-of-date.");
      return;
    }
    BoneCPDataSource dataSource = (BoneCPDataSource) getDbConnector().getDataSource();
    String jdbcUrl = dataSource.getJdbcUrl();
    if (jdbcUrl == null) {
      throw new OpenGammaRuntimeException("No JDBC URL specified");
    }
    DbManagement dbManagement = DbManagementUtils.getDbManagement(jdbcUrl);
    int lastSlashIdx = jdbcUrl.lastIndexOf("/");
    if (lastSlashIdx == -1) {
      throw new OpenGammaRuntimeException("JDBC URL must contain '/' before the database name");
    }

    // REVIEW jonathan 2013-05-14 -- should not be doing this (PLAT-2745)
    int lastSlash = jdbcUrl.lastIndexOf('/');
    if (lastSlash == -1 || lastSlash == jdbcUrl.length() - 1) {
      throw new OpenGammaRuntimeException("JDBC URL must contain a slash separating the server host and the database name");
    }
    String dbServerHost = jdbcUrl.substring(0, lastSlash);
    String catalog = jdbcUrl.substring(lastSlashIdx + 1);
    String user = dataSource.getUsername();
    String password = dataSource.getPassword();
    dbManagement.initialise(dbServerHost, user, password);
   
    Integer expectedSchemaVersion = DbScriptUtils.getCurrentVersion(schemaName);
    if (expectedSchemaVersion == null) {
      throw new OpenGammaRuntimeException("Unable to find schema version information for " + schemaName + ". Database objects cannot be managed.");
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

   * @return the data source, not null
   */
  public synchronized DataSource getDataSource() {
    DataSource dataSource = _dataSource;
    if (dataSource == null) {
      BoneCPDataSource ds = new BoneCPDataSource();
      ds.setPoolName("DbTool-" + _dialect.getDatabaseName());
      ds.setDriverClass(_dialect.getJDBCDriverClass().getName());
      ds.setJdbcUrl(getJdbcUrl());
      ds.setUsername(getUser());
      ds.setPassword(getPassword());
      ds.setAcquireIncrement(1);
      ds.setPartitionCount(1);
      ds.setMaxConnectionsPerPartition(1);
      ds.setAcquireRetryAttempts(2);
      ds.setAcquireRetryDelayInMs(2000);
      _dataSource = dataSource = ds;  // CSIGNORE
    }
    return dataSource;
  }
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

    new DbConnector(null, null, null, null, null, null);
  }

  //-------------------------------------------------------------------------
  public void test_basics() {
    BoneCPDataSource ds = new BoneCPDataSource();
    HSQLDbDialect dialect = HSQLDbDialect.INSTANCE;
    NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(ds);
    DefaultTransactionDefinition transDefn = new DefaultTransactionDefinition();
    DataSourceTransactionManager transMgr = new DataSourceTransactionManager();
    TransactionTemplate transTemplate = new TransactionTemplate(transMgr, transDefn);
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

    test.close();
  }

  //-------------------------------------------------------------------------
  public void test_toString() {
    BoneCPDataSource ds = new BoneCPDataSource();
    HSQLDbDialect dialect = HSQLDbDialect.INSTANCE;
    NamedParameterJdbcTemplate jdbcTemplate = new NamedParameterJdbcTemplate(ds);
    DefaultTransactionDefinition transDefn = new DefaultTransactionDefinition();
    DataSourceTransactionManager transMgr = new DataSourceTransactionManager();
    TransactionTemplate transTemplate = new TransactionTemplate(transMgr, transDefn);
View Full Code Here

Examples of com.jolbox.bonecp.BoneCPDataSource

        assertThat(db.getName(), equalTo("test"));
        assertThat(db.getUrl(), equalTo("jdbc:h2:mem:test"));

        DataSource ds = db.getDataSource();
        if (ds instanceof BoneCPDataSource) {
            BoneCPDataSource bcp = (BoneCPDataSource) ds;
            assertThat(bcp.getJdbcUrl(), equalTo("jdbc:h2:mem:test;MODE=MySQL"));
        }

        db.shutdown();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.