Package com.jolbox.bonecp

Examples of com.jolbox.bonecp.BoneCPConfig


    public static final int DEFAULT_PARTITION_COUNT = 4;
    private final BoneCP _connectionPool;

    public BoneCPConnectionProvider(String connectionUrl, VirtualHost virtualHost) throws SQLException
    {
        BoneCPConfig config = new BoneCPConfig();
        config.setJdbcUrl(connectionUrl);


        config.setMinConnectionsPerPartition(getIntegerAttribute(virtualHost, "minConnectionsPerPartition", DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
        config.setMaxConnectionsPerPartition(getIntegerAttribute(virtualHost, "maxConnectionsPerPartition", DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
        config.setPartitionCount(getIntegerAttribute(virtualHost, "partitionCount",DEFAULT_PARTITION_COUNT));
        _connectionPool = new BoneCP(config);
    }
View Full Code Here


     */
    private final BoneCP connectionPool;

    protected BasePooledConnectionProvider(Configuration pluginConfig) throws Exception {
        this.pluginConfig = pluginConfig;
        BoneCPConfig bconfig = new BoneCPConfig(getConnectionProperties());
        Class<Driver> driverClass;
        try {
            driverClass = getDriverClass();
        } catch (ClassNotFoundException e) {
            LOG.warn("Could not load driver class from: " + Thread.currentThread().getContextClassLoader());
            throw e;
        }
        if (driverClass != null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Using driver class " + driverClass);
            }
            Driver driver = driverClass.newInstance();
            DataSource datasourceBean = new DriverDataSource(driver, getJdbcUrl(), getConnectionProperties());
            bconfig.setDatasourceBean(datasourceBean);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Using driver manager for " + getJdbcUrl());
            }
            bconfig.setJdbcUrl(getJdbcUrl());
        }
        bconfig.setAcquireIncrement(1);
        bconfig.setAcquireRetryAttempts(0);
        bconfig.setAcquireRetryDelayInMs(0);
        bconfig.setPartitionCount(2);
        bconfig.setMaxConnectionsPerPartition(5);
        bconfig.setPassword(getPassword());
        bconfig.setUsername(getUsername());
        bconfig.setConnectionTimeoutInMs(getConnectionTimeout());
        if (isTrack()) {
            bconfig.setCloseConnectionWatch(true);
            bconfig.setCloseConnectionWatchTimeout(10, TimeUnit.MINUTES);
        }
        bconfig.setLazyInit(false);
        bconfig.setDisableJMX(true);
        // Do not manage retry
        ConnectionHook hook = new AbstractConnectionHook() {
            public boolean onAcquireFail(Throwable t, AcquireFailConfig acquireConfig) {
                LOG.error("Failed to obtain connection", t);
                return false;
            }
        };
        bconfig.setConnectionHook(hook);
        connectionPool = new BoneCP(bconfig);
    }
View Full Code Here

      String dbdriver) throws Exception{
    loadProperties();
    if(connectionPool == null){
      dbifaceClass = Class.forName(dbclassname);
      Class.forName(dbdriver);
      BoneCPConfig config = new BoneCPConfig();
      config.setJdbcUrl(dbconnect);
      config.setMinConnectionsPerPartition(
          Integer.parseInt(properties.getProperty(DBMINCONKEY)));
      config.setMaxConnectionsPerPartition(
          Integer.parseInt(properties.getProperty(DBMAXCONKEY)));
      config.setAcquireRetryAttempts(
          Integer.parseInt(properties.getProperty(DBRETRYATTEMPTSKEY)));
      config.setAcquireRetryDelayInMs(
          Long.parseLong(properties.getProperty(DBRETRYDELAYKEY)));
      config.setLogStatementsEnabled(true);
      config.setPartitionCount(
          Integer.parseInt(properties.getProperty(DBPARTKEY)));
      connectionPool = new BoneCP(config);
    }
  }
View Full Code Here

 
  /**
   * 创建BoneCP数据源连接池
   */
  protected BoneCPDataSource createBoneCP( ){
    BoneCPConfig config = new BoneCPConfig();
    try {
      Class.forName( this.getDriverClassName() );
    } catch (ClassNotFoundException e) {
      throw new ApplicationException(
          "初始化连接池[BoneCP]无法找到驱动["
          +getDriverClassName()+"]:",e);
    }
    config.setJdbcUrl( this.getUrl() );
    config.setUsername( this.getUsername() );
    config.setPassword( this.getPassword() );
   
    config.setPartitionCount( this.getPartitionCount() );
    config.setAcquireIncrement(this.getAcquireIncrement());
    config.setMinConnectionsPerPartition(getMinConnectionsPerPartition());
    config.setMaxConnectionsPerPartition(getMaxConnectionsPerPartition());
    if( getTimeoutInSeconds() > 0 )
      config.setConnectionTimeout(getTimeoutInSeconds(),TimeUnit.SECONDS );
   
    config.setIdleMaxAgeInSeconds(getIdleMaxAgeInSeconds());
    config.setIdleConnectionTestPeriodInSeconds(getIdleConnectionTestPeriodInSeconds());
    config.setReleaseHelperThreads(getReleaseHelperThreads());
    config.setStatementsCacheSize(getStatementsCacheSize());
   
    BoneCPDataSource bonecp = new BoneCPDataSource(config);
    log.info("BoneCP连接池创建完成!");
    return bonecp;
  }
View Full Code Here

  private BoneCP pool;
 
  public FlyDB(String jdbc, String user, String pass) throws SQLException, PropertyVetoException, Exception {
    Class.forName("java.sql.Driver");
   
    BoneCPConfig config = new BoneCPConfig();
      config.setJdbcUrl(jdbc);
      config.setUsername(user);
      config.setPassword(pass);
     
      config.setMinConnectionsPerPartition(5);
    config.setMaxConnectionsPerPartition(20);
    config.setPartitionCount(1);
     
      pool = new BoneCP(config);
  }
View Full Code Here

        ((BoneCPDataSource) dataSource).close();
    }

    @Override
    public DataSource pool(final String name, final DataSource ds, final Properties properties) {
        final BoneCPConfig config;
        final BoneCP pool;
        try {
            config = new BoneCPConfig(prefixedProps(properties));
            pool = new BoneCP(config);
        } catch (final Exception e) {
            throw new IllegalArgumentException(e);
        }
        return build(BoneCPDataSourceProvidedPool.class, new BoneCPDataSourceProvidedPool(pool), new Properties());
View Full Code Here

    statement.executeUpdate(builder.toString());
  }
 
    public static void main(String args[]) throws ClassNotFoundException, ParserConfigurationException, SAXException, IOException, SQLException, ParseException {
        long time;
        BoneCPConfig configuration;
        BoneCPDataSource dataSource;
        InputStream stream;
        InputSource inputSource;
        SequentialOrdersImporter importer;
       
        if (args.length != 4) {
            System.out.println("Usage: java " + SequentialOrdersImporter.class.getName() + " URL USER PASSWORD FILE");
            return;
        }
        time = System.currentTimeMillis();
        dataSource = null;
        stream = null;
        try {
          Class.forName("com.mysql.jdbc.Driver");
          configuration = new BoneCPConfig();
          configuration.setJdbcUrl(args[0]);
          configuration.setUsername(args[1]);
          configuration.setPassword(args[2]);
          dataSource = new BoneCPDataSource(configuration);
            stream = new FileInputStream(args[3]);
            inputSource = new InputSource(stream);
            importer = new SequentialOrdersImporter();
            importer.importOrders(dataSource, inputSource);
View Full Code Here

          }
        }
       
        public static void main(String args[]) throws ClassNotFoundException, SQLException, ParserConfigurationException, SAXException, IOException, InterruptedException, VerticesProcessingException {
          long time;
          BoneCPConfig configuration;
          BoneCPDataSource dataSource;
          InputStream stream;
          InputSource inputSource;
          OrdersImporter importer;
         
          if (args.length != 4) {
              System.out.println("Usage: java " + OrdersImporter.class.getName() + " URL USER PASSWORD FILE");
              return;
          }
          time = System.currentTimeMillis();
          dataSource = null;
          stream = null;
          try {
          Class.forName("com.mysql.jdbc.Driver");
          configuration = new BoneCPConfig();
          configuration.setJdbcUrl(args[0]);
          configuration.setUsername(args[1]);
          configuration.setPassword(args[2]);
          dataSource = new BoneCPDataSource(configuration);
            stream = new FileInputStream(args[3]);
            inputSource = new InputSource(stream);
            importer = new OrdersImporter();
            importer.importOrders(dataSource, inputSource);
View Full Code Here

    catch (ClassNotFoundException e)
    {
      throw new ConfigBite("Driver not found", e);
    }

    BoneCPConfig bcpConfig = new BoneCPConfig();

    bcpConfig.setJdbcUrl(config.getConnectionString());
    bcpConfig.setUsername(config.getUsername());
    bcpConfig.setPassword(config.getPassword());
    bcpConfig.setMinConnectionsPerPartition(5);
    bcpConfig.setMaxConnectionsPerPartition(10);
    bcpConfig.setPartitionCount(1);

    try
    {
      connectionPool = new BoneCP(bcpConfig);
    }
View Full Code Here

    private final BoneCP _connectionPool;

    public BoneCPConnectionProvider(String connectionUrl, String username, String password, Map<String, String> providerAttributes) throws SQLException
    {
        BoneCPConfig config = new BoneCPConfig();
        config.setJdbcUrl(connectionUrl);
        if (username != null)
        {
            config.setUsername(username);
            config.setPassword(password);
        }

        config.setMinConnectionsPerPartition(convertToIntWithDefault(MIN_CONNECTIONS_PER_PARTITION, providerAttributes, DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
        config.setMaxConnectionsPerPartition(convertToIntWithDefault(MAX_CONNECTIONS_PER_PARTITION, providerAttributes, DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
        config.setPartitionCount(convertToIntWithDefault(PARTITION_COUNT, providerAttributes, DEFAULT_PARTITION_COUNT));

        _connectionPool = new BoneCP(config);
    }
View Full Code Here

TOP

Related Classes of com.jolbox.bonecp.BoneCPConfig

Copyright © 2018 www.massapicom. 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.