Package org.apache.commons.pool.impl

Examples of org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory


    }

    LOGGER.debug("Max active connections for the pool: " + maxActive);
    connectionPool.setMaxActive(maxActive);

    statementPool = new GenericKeyedObjectPoolFactory(null);

    // Creating the factory instance automatically wires the connection pool
    new PoolableConnectionFactory(connFactory, connectionPool, statementPool,
        databaseType.getValidationQuery(), false, false,
        txIsolationLevel.getCode());
View Full Code Here


    }

    LOGGER.debug("Max active connections for the pool: " + maxActive);
    connectionPool.setMaxActive(maxActive);

    statementPool = new GenericKeyedObjectPoolFactory(null);

    // Creating the factory instance automatically wires the connection pool
    new PoolableConnectionFactory(connFactory, connectionPool, statementPool,
        databaseType.getValidationQuery(), false, false,
        txIsolationLevel.getCode());
View Full Code Here

            // mkalen: let the platform set Oracle-specific statement pooling
            return null;
        }

        // Set up statement pool, if desired
        GenericKeyedObjectPoolFactory statementPoolFactory = null;
        final Properties properties = jcd.getConnectionPoolDescriptor().getDbcpProperties();
        final String poolStmtParam = properties.getProperty(PARAM_NAME_POOL_STATEMENTS);
        if (poolStmtParam != null && Boolean.valueOf(poolStmtParam).booleanValue())
        {
            int maxOpenPreparedStatements = GenericKeyedObjectPool.DEFAULT_MAX_TOTAL;
            final String maxOpenPrepStmtString = properties.getProperty(PARAM_NAME_STATEMENT_POOL_MAX_TOTAL);
            if (maxOpenPrepStmtString != null)
            {
                maxOpenPreparedStatements = Integer.parseInt(maxOpenPrepStmtString);
            }
            // Use the same values as Commons DBCP BasicDataSource
            statementPoolFactory = new GenericKeyedObjectPoolFactory(null,
                        -1, // unlimited maxActive (per key)
                        GenericKeyedObjectPool.WHEN_EXHAUSTED_FAIL,
                        0, // maxWait
                        1, // maxIdle (per key)
                        maxOpenPreparedStatements);
View Full Code Here

          maxOpenPreparedStatements =
              Integer.parseInt( attributes.get( IDBDatasourceService.MAX_OPEN_PREPARED_STATEMENTS ) );
        }

        kopf =
            new GenericKeyedObjectPoolFactory( null, pool.getMaxActive(), pool.getWhenExhaustedAction(), pool
                .getMaxWait(), pool.getMaxIdle(), maxOpenPreparedStatements );
      }

      /*
       * Puts pool-specific wrappers on factory connections. For clarification: "[PoolableConnection]Factory," not
View Full Code Here

            if ("oracle".equals(ConfigurationManager.getProperty("db.name")))
            {
                validationQuery = "SELECT 1 FROM DUAL";
            }

            GenericKeyedObjectPoolFactory statementFactory = null;
            if (useStatementPool)
            {
              // The statement Pool is used to pool prepared statements.
              GenericKeyedObjectPool.Config statementFactoryConfig = new GenericKeyedObjectPool.Config();
              // Just grow the pool size when needed.
              //
              // This means we will never block when attempting to
              // create a query. The problem is unclosed statements,
              // they can never be reused. So if we place a maximum
              // cap on them, then we might reach a condition where
              // a page can only be viewed X number of times. The
              // downside of GROW_WHEN_EXHAUSTED is that this may
              // allow a memory leak to exist. Both options are bad,
              // but I'd prefer a memory leak over a failure.
              //
              // FIXME: Perhaps this decision should be derived from config parameters?
              statementFactoryConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;
 
              statementFactory = new GenericKeyedObjectPoolFactory(null,statementFactoryConfig);
            }
           
            PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                    connectionFactory, connectionPool, statementFactory,
                    validationQuery, // validation query
View Full Code Here

        factoryConfig.testWhileIdle = true;
        factoryConfig.testOnReturn = true;
        factoryConfig.numTestsPerEvictionRun = factoryConfig.maxTotal;
        factoryConfig.minEvictableIdleTimeMillis = 30 * 1000;
        */
        stmtPoolFactory = new GenericKeyedObjectPoolFactory(objectFactory, factoryConfig);
        return stmtPoolFactory;
    }
View Full Code Here

        new DriverManagerConnectionFactory(connectUrl, jdbcProps);

    connectionPool = new GenericObjectPool();
    connectionPool.setMaxActive(repoContext.getMaximumConnections());

    statementPool = new GenericKeyedObjectPoolFactory(null);

    // creating the factor automatically wires the connection pool
    new PoolableConnectionFactory(connFactory, connectionPool, statementPool,
        handler.validationQuery(), false, false,
        repoContext.getTransactionIsolation().getCode());
View Full Code Here

    connectionPool.setTestWhileIdle(true);
    connectionPool.setTimeBetweenEvictionRunsMillis(idleTestPeriod * 1000L);
    connectionPool.setNumTestsPerEvictionRun(maxActive);
    connectionPool.setMinEvictableIdleTimeMillis(idleTimeOut * 1000L);

    GenericKeyedObjectPoolFactory statementPoolFactory = null;
    if(poolPreparedStatements)
      statementPoolFactory = new GenericKeyedObjectPoolFactory(null, -1, GenericObjectPool.WHEN_EXHAUSTED_FAIL, 0L, 1, GenericKeyedObjectPool.DEFAULT_MAX_TOTAL);

    Properties connectionProperties = new Properties();
    connectionProperties.put("user", uname);
    connectionProperties.put("password", passwd);

View Full Code Here

            //
            // Now we'll create the PoolableConnectionFactory, which wraps
            // the "real" Connections created by the ConnectionFactory with
            // the classes that implement the pooling functionality.
            //
            GenericKeyedObjectPoolFactory statementFactory = null;
            if (useStatementPool)
            {
                // The statement Pool is used to pool prepared statements.
                GenericKeyedObjectPool.Config statementFactoryConfig = new GenericKeyedObjectPool.Config();
                // Just grow the pool size when needed.
                //
                // This means we will never block when attempting to
                // create a query. The problem is unclosed statements,
                // they can never be reused. So if we place a maximum
                // cap on them, then we might reach a condition where
                // a page can only be viewed X number of times. The
                // downside of GROW_WHEN_EXHAUSTED is that this may
                // allow a memory leak to exist. Both options are bad,
                // but I'd prefer a memory leak over a failure.
                //
                // FIXME: Perhaps this decision should be derived from config parameters?
                statementFactoryConfig.whenExhaustedAction = GenericObjectPool.WHEN_EXHAUSTED_GROW;

                statementFactory = new GenericKeyedObjectPoolFactory(null,statementFactoryConfig);
            }

            PoolableConnectionFactory poolableConnectionFactory = new PoolableConnectionFactory(
                    connectionFactory, connectionPool, statementFactory,
                    null, // validation query (none until we know DBMS brand)
View Full Code Here

        return new DriverManagerConnectionFactory(getDbURL(jcd), jcd.getUserName(), jcd.getPassWord());
    }

    protected KeyedObjectPoolFactory createStatementPoolFactory(Object obj)
    {
        return new GenericKeyedObjectPoolFactory(null);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.pool.impl.GenericKeyedObjectPoolFactory

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.