Search in sources :

Example 6 with PoolConfiguration

use of org.apache.tomcat.jdbc.pool.PoolConfiguration in project tomcat by apache.

the class TestSizePreservation method initSimplePoolProperties.

private void initSimplePoolProperties() {
    PoolConfiguration p = new DefaultProperties();
    ds = new org.apache.tomcat.jdbc.pool.DataSource();
    ds.setPoolProperties(p);
    ds.getPoolProperties().setDriverClassName(Driver.class.getName());
    ds.getPoolProperties().setUrl(Driver.url);
    ds.getPoolProperties().setFairQueue(true);
    ds.getPoolProperties().setJmxEnabled(false);
    ds.getPoolProperties().setTestWhileIdle(true);
    ds.getPoolProperties().setTestOnBorrow(false);
    ds.getPoolProperties().setTestOnReturn(false);
    ds.getPoolProperties().setValidationInterval(30000);
    ds.getPoolProperties().setTimeBetweenEvictionRunsMillis(30000);
    ds.getPoolProperties().setInitialSize(100);
    ds.getPoolProperties().setMaxActive(100);
    ds.getPoolProperties().setMinIdle(0);
    ds.getPoolProperties().setMaxIdle(0);
    ds.getPoolProperties().setMaxWait(10000);
    ds.getPoolProperties().setRemoveAbandonedTimeout(10);
    ds.getPoolProperties().setMinEvictableIdleTimeMillis(10000);
    ds.getPoolProperties().setLogAbandoned(false);
    ds.getPoolProperties().setRemoveAbandoned(false);
    ds.getPoolProperties().setUseLock(true);
}
Also used : PoolConfiguration(org.apache.tomcat.jdbc.pool.PoolConfiguration) Driver(org.apache.tomcat.jdbc.test.driver.Driver) DataSource(org.apache.tomcat.jdbc.pool.DataSource)

Example 7 with PoolConfiguration

use of org.apache.tomcat.jdbc.pool.PoolConfiguration in project sling by apache.

the class DataSourceFactory method createPoolConfig.

private PoolConfiguration createPoolConfig(Map<String, ?> config) {
    Properties props = new Properties();
    //Copy the other properties first
    Map<String, String> otherProps = PropertiesUtil.toMap(config.get(PROP_DATASOURCE_SVC_PROPS), new String[0]);
    for (Map.Entry<String, String> e : otherProps.entrySet()) {
        set(e.getKey(), e.getValue(), props);
    }
    props.setProperty(org.apache.tomcat.jdbc.pool.DataSourceFactory.OBJECT_NAME, name);
    for (String propName : DummyDataSourceFactory.getPropertyNames()) {
        String value = PropertiesUtil.toString(config.get(propName), null);
        set(propName, value, props);
    }
    //Specify the DataSource such that connection creation logic is handled
    //by us where we take care of OSGi env
    PoolConfiguration poolProperties = org.apache.tomcat.jdbc.pool.DataSourceFactory.parsePoolProperties(props);
    poolProperties.setDataSource(createDriverDataSource(poolProperties));
    return poolProperties;
}
Also used : PoolConfiguration(org.apache.tomcat.jdbc.pool.PoolConfiguration) PoolProperties(org.apache.tomcat.jdbc.pool.PoolProperties) Properties(java.util.Properties) Map(java.util.Map)

Example 8 with PoolConfiguration

use of org.apache.tomcat.jdbc.pool.PoolConfiguration in project tomee by apache.

the class TomEEDataSourceCreator method pool.

@Override
public CommonDataSource pool(final String name, final String driver, final Properties properties) {
    final PoolConfiguration config = build(TomEEPoolProperties.class, createProperties(name, properties));
    final TomEEDataSource ds = new TomEEDataSource(config, name);
    recipes.put(ds, recipes.remove(config));
    return ds;
}
Also used : PoolConfiguration(org.apache.tomcat.jdbc.pool.PoolConfiguration)

Example 9 with PoolConfiguration

use of org.apache.tomcat.jdbc.pool.PoolConfiguration in project tomee by apache.

the class TomEEDataSourceCreator method pool.

@Override
public DataSource pool(final String name, final DataSource ds, final Properties properties) {
    final PoolConfiguration config = build(TomEEPoolProperties.class, createProperties(name, properties));
    config.setDataSource(ds);
    final ConnectionPool pool;
    try {
        pool = new ConnectionPool(config);
    } catch (final SQLException e) {
        throw new IllegalStateException(e);
    }
    final TomEEDataSource dataSource = new TomEEDataSource(config, pool, name);
    // transfer unset props for correct logging
    recipes.put(dataSource, recipes.remove(config));
    return dataSource;
}
Also used : ConnectionPool(org.apache.tomcat.jdbc.pool.ConnectionPool) PoolConfiguration(org.apache.tomcat.jdbc.pool.PoolConfiguration) SQLException(java.sql.SQLException)

Aggregations

PoolConfiguration (org.apache.tomcat.jdbc.pool.PoolConfiguration)9 Connection (java.sql.Connection)3 SQLException (java.sql.SQLException)3 Statement (java.sql.Statement)3 DataSource (org.apache.tomcat.jdbc.pool.DataSource)3 PoolProperties (org.apache.tomcat.jdbc.pool.PoolProperties)3 ResultSet (java.sql.ResultSet)2 ConnectionPool (org.apache.tomcat.jdbc.pool.ConnectionPool)2 CallableStatement (java.sql.CallableStatement)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Properties (java.util.Properties)1 DefaultProperties (org.apache.tomcat.jdbc.test.DefaultProperties)1 Driver (org.apache.tomcat.jdbc.test.driver.Driver)1