List of usage examples for org.apache.commons.dbcp PoolingDataSource setLogWriter
public void setLogWriter(PrintWriter out)
From source file:org.apache.ojb.broker.accesslayer.ConnectionFactoryDBCPImpl.java
/** * Wraps the specified object pool for connections as a DataSource. * * @param jcd the OJB connection descriptor for the pool to be wrapped * @param connectionPool the connection pool to be wrapped * @return a DataSource attached to the connection pool. * Connections will be wrapped using DBCP PoolGuard, that will not allow * unwrapping unless the "accessToUnderlyingConnectionAllowed=true" configuration * is specified.// w ww .j a v a2 s.com */ protected DataSource wrapAsDataSource(JdbcConnectionDescriptor jcd, ObjectPool connectionPool) { final boolean allowConnectionUnwrap; if (jcd == null) { allowConnectionUnwrap = false; } else { final Properties properties = jcd.getConnectionPoolDescriptor().getDbcpProperties(); final String allowConnectionUnwrapParam; allowConnectionUnwrapParam = properties.getProperty(PARAM_NAME_UNWRAP_ALLOWED); allowConnectionUnwrap = allowConnectionUnwrapParam != null && Boolean.valueOf(allowConnectionUnwrapParam).booleanValue(); } final PoolingDataSource dataSource; dataSource = new PoolingDataSource(connectionPool); dataSource.setAccessToUnderlyingConnectionAllowed(allowConnectionUnwrap); if (jcd != null) { final AbandonedConfig ac = jcd.getConnectionPoolDescriptor().getAbandonedConfig(); if (ac.getRemoveAbandoned() && ac.getLogAbandoned()) { final LoggerWrapperPrintWriter loggerPiggyBack; loggerPiggyBack = new LoggerWrapperPrintWriter(log, Logger.ERROR); dataSource.setLogWriter(loggerPiggyBack); } } return dataSource; }