@Override public synchronized boolean isAccessToUnderlyingConnectionAllowed() { return delegate.isAccessToUnderlyingConnectionAllowed(); }
/** * Creates the actual data source instance. This method only exists so * subclasses can replace the implementation class. * * @throws SQLException if unable to create a datasource instance */ protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new PoolingDataSource(connectionPool); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
/** * Creates the actual data source instance. This method only exists so * subclasses can replace the implementation class. * * @throws SQLException if unable to create a datasource instance */ protected void createDataSourceInstance() throws SQLException { PoolingDataSource pds = new PoolingDataSource(connectionPool); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); pds.setLogWriter(logWriter); dataSource = pds; }
/** * This method gets a {@link Connection} from the {@link DataSource} and checks if it is a {@link oracle.jdbc.driver.OracleConnection}. * There is a bug with commons-dbcp 1.4: if you want to create a {@link oracle.sql.BLOB} or a {@link java.sql.Clob} than you must get the inner {@link Connection} but you get another {@link Connection}. * This is fixed in this method. * @param connection * @param dataSource * @return */ public static Connection getGoodConnection(Connection connection, DataSource dataSource) { if (dataSource instanceof BasicDataSource) { BasicDataSource tempDataSource = (BasicDataSource) dataSource; if (tempDataSource.getDriverClassName().toLowerCase().contains("oracle") && connection instanceof DelegatingConnection) { boolean canAccess = tempDataSource.isAccessToUnderlyingConnectionAllowed(); if (!canAccess) { tempDataSource.setAccessToUnderlyingConnectionAllowed(true); } DelegatingConnection tempConnection = (DelegatingConnection) connection; Connection innermostDelegate = tempConnection.getInnermostDelegate(); if (!canAccess) { tempDataSource.setAccessToUnderlyingConnectionAllowed(false); } return innermostDelegate; } } return connection; } }
((PoolingDataSource) dataSource).setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); dataSource.setLogWriter(logWriter);