List of usage examples for org.apache.commons.dbcp BasicDataSource getLogWriter
public PrintWriter getLogWriter() throws SQLException
Returns the log writer being used by this data source.
Calls #createDataSource() , so has the side effect of initializing the connection pool.
From source file:se.unlogic.hierarchy.core.cache.DataSourceCache.java
private DataSource getDataSourceInstance(DataSourceDescriptor dataSourceDescriptor) throws SQLException, DataSourceNotFoundInContextException { if (dataSourceDescriptor.getType() == DataSourceType.ContainerManaged) { try {/* w w w. j av a2s.c o m*/ return DBUtils.getDataSource(dataSourceDescriptor.getUrl()); } catch (NamingException e) { throw new DataSourceNotFoundInContextException(dataSourceDescriptor, e); } } else { BasicDataSource basicDataSource = DBCPUtils.createConnectionPool(dataSourceDescriptor); try { //Dummy call to initialize connection pool basicDataSource.getLogWriter(); return basicDataSource; } catch (SQLException e) { if (basicDataSource != null) { try { basicDataSource.close(); } catch (SQLException e1) { log.error("Error closing data source after failed initialization", e); } } throw e; } } }