Example usage for org.apache.commons.dbcp BasicDataSource getLogAbandoned

List of usage examples for org.apache.commons.dbcp BasicDataSource getLogAbandoned

Introduction

In this page you can find the example usage for org.apache.commons.dbcp BasicDataSource getLogAbandoned.

Prototype

public boolean getLogAbandoned() 

Source Link

Document

Flag to log stack traces for application code which abandoned a Statement or Connection.

Usage

From source file:org.alfresco.repo.tenant.TenantBasicDataSource.java

public TenantBasicDataSource(BasicDataSource bds, String tenantUrl, int tenantMaxActive) throws SQLException {
    // tenant-specific
    this.setUrl(tenantUrl);
    this.setMaxActive(tenantMaxActive == -1 ? bds.getMaxActive() : tenantMaxActive);

    // defaults/overrides - see also 'baseDefaultDataSource' (core-services-context.xml + repository.properties)

    this.setDriverClassName(bds.getDriverClassName());
    this.setUsername(bds.getUsername());
    this.setPassword(bds.getPassword());

    this.setInitialSize(bds.getInitialSize());
    this.setMinIdle(bds.getMinIdle());
    this.setMaxIdle(bds.getMaxIdle());
    this.setDefaultAutoCommit(bds.getDefaultAutoCommit());
    this.setDefaultTransactionIsolation(bds.getDefaultTransactionIsolation());
    this.setMaxWait(bds.getMaxWait());
    this.setValidationQuery(bds.getValidationQuery());
    this.setTimeBetweenEvictionRunsMillis(bds.getTimeBetweenEvictionRunsMillis());
    this.setMinEvictableIdleTimeMillis(bds.getMinEvictableIdleTimeMillis());
    this.setNumTestsPerEvictionRun(bds.getNumTestsPerEvictionRun());
    this.setTestOnBorrow(bds.getTestOnBorrow());
    this.setTestOnReturn(bds.getTestOnReturn());
    this.setTestWhileIdle(bds.getTestWhileIdle());
    this.setRemoveAbandoned(bds.getRemoveAbandoned());
    this.setRemoveAbandonedTimeout(bds.getRemoveAbandonedTimeout());
    this.setPoolPreparedStatements(bds.isPoolPreparedStatements());
    this.setMaxOpenPreparedStatements(bds.getMaxOpenPreparedStatements());
    this.setLogAbandoned(bds.getLogAbandoned());
}

From source file:org.pentaho.di.core.database.PoolableDataSourceTest.java

@Test
public void testPropertiesAreSet() throws Exception {
    Connection conn = null;//from  ww w .j ava  2 s.c  o  m
    try {
        conn = getConnection();
        Field field = ConnectionPoolUtil.class.getDeclaredField("dataSources");
        assertNotNull("Can't find field 'dataSources' in class ConnectionPoolUtil", field);
        field.setAccessible(true);
        Map<String, BasicDataSource> dataSources = (Map<String, BasicDataSource>) field
                .get(ConnectionPoolUtil.class);
        BasicDataSource ds = dataSources.get(dbMeta.getName());

        assertEquals(true, ds.getDefaultAutoCommit());
        assertEquals(true, ds.getDefaultReadOnly());
        assertEquals(1, ds.getDefaultTransactionIsolation());
        assertEquals(null, ds.getDefaultCatalog());
        assertEquals(30, ds.getMaxIdle());
        assertEquals(3, ds.getMinIdle());
        assertEquals(MAX_WAIT_TIME, ds.getMaxWait());
        assertEquals(VALIDATION_QUERY, ds.getValidationQuery());
        assertEquals(true, ds.getTestOnBorrow());
        assertEquals(true, ds.getTestOnReturn());
        assertEquals(true, ds.getTestWhileIdle());
        assertEquals(300000, ds.getTimeBetweenEvictionRunsMillis());
        assertEquals(true, ds.isPoolPreparedStatements());
        assertEquals(2, ds.getMaxOpenPreparedStatements());
        assertEquals(true, ds.isAccessToUnderlyingConnectionAllowed());
        assertEquals(false, ds.getRemoveAbandoned());
        assertEquals(1000, ds.getRemoveAbandonedTimeout());
        assertEquals(false, ds.getLogAbandoned());
    } finally {
        DatabaseUtil.closeSilently(conn);
    }
}