Example usage for org.apache.commons.dbcp.datasources SharedPoolDataSource setTimeBetweenEvictionRunsMillis

List of usage examples for org.apache.commons.dbcp.datasources SharedPoolDataSource setTimeBetweenEvictionRunsMillis

Introduction

In this page you can find the example usage for org.apache.commons.dbcp.datasources SharedPoolDataSource setTimeBetweenEvictionRunsMillis.

Prototype

public void setTimeBetweenEvictionRunsMillis(int timeBetweenEvictionRunsMillis) 

Source Link

Document

Sets the number of milliseconds to sleep between runs of the idle object evictor thread.

Usage

From source file:com.silverpeas.wysiwyg.dynamicvalue.pool.ConnectionPoolWithJDBC.java

/**
 * Initializes the datasource. This datasource is based on the SharedPoolDataSource class, a dbcp
 * implementation//from www  . ja va 2  s  .  co  m
 */
private synchronized static void initializeDatasource() {
    SilverTrace.debug("wysiwyg", ConnectionPoolWithJDBC.class.toString(),
            " Datasource initialization : starting ...");
    if (ds == null) {
        // check if the information for the pool creation is present.
        if (poolInfo == null) {
            SilverTrace.error("wysiwig", ConnectionPoolWithJDBC.class.toString(),
                    "wysiwig.CONNECTION_INIALIZATION_FAILED");
            throw new TechnicalException(ConnectionPoolWithJDBC.class.toString()
                    + " : An error occurred  during the connection initialization. The Pool information must be set");
        }
        SilverTrace.debug("wysiwyg", ConnectionPoolWithJDBC.class.toString(),
                " Datasource initialization : poolInfo detail :: " + poolInfo.toString());

        // driver registration
        DriverAdapterCPDS cpds = new DriverAdapterCPDS();
        try {
            cpds.setDriver(poolInfo.getDriver());
        } catch (ClassNotFoundException e) {
            SilverTrace.error("wysiwig", ConnectionPoolWithJDBC.class.toString(), "wysiwig.DRIVER_MISSING");
            throw new TechnicalException(ConnectionPoolWithJDBC.class.toString()
                    + " : An error occurred  during the connection initializatoin. The JDBC driver isn't in the classpath",
                    e);
        }
        cpds.setUrl(poolInfo.getUrl());
        cpds.setUser(poolInfo.getUser());
        cpds.setPassword(poolInfo.getPassword());

        // datasource object creation
        SharedPoolDataSource tds = new SharedPoolDataSource();
        tds.setConnectionPoolDataSource(cpds);
        tds.setMaxActive(poolInfo.getMaxActive());
        tds.setMaxWait(poolInfo.getMaxWait());
        tds.setMaxIdle(poolInfo.getMaxIdle());
        tds.setTimeBetweenEvictionRunsMillis(poolInfo.getTimeBetweenEvictionRunsMillis());
        tds.setNumTestsPerEvictionRun(poolInfo.getNumTestsPerEvictionRun());
        tds.setMinEvictableIdleTimeMillis(poolInfo.getMinEvictableIdleTimeMillis());
        ds = tds;
        SilverTrace.debug("wysiwyg", ConnectionPoolWithJDBC.class.toString(),
                " Datasource initialization : ending ...");
    }
}