JAVA-7334: Update 'Oracle Connection Pooling With Spring' article

This commit is contained in:
Rafael Lopez
2021-09-19 17:56:49 -04:00
parent 2c837e030f
commit e03662dd54
5 changed files with 16 additions and 36 deletions
@@ -20,7 +20,8 @@ public class OracleConfiguration {
dataSource.setUser("books");
dataSource.setPassword("books");
dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1");
dataSource.setFastConnectionFailoverEnabled(true);
// Only with clients prior to v21
// dataSource.setFastConnectionFailoverEnabled(true);
dataSource.setImplicitCachingEnabled(true);
// Only with clients prior to v11.2
// dataSource.setConnectionCachingEnabled(true);
@@ -1,32 +0,0 @@
package com.baeldung.spring.oracle.pooling.configuration;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import oracle.ucp.jdbc.PoolDataSource;
import oracle.ucp.jdbc.PoolDataSourceFactory;
@Configuration
@Profile("oracle-ucp")
public class OracleUCPConfiguration {
@Bean
public DataSource dataSource() throws SQLException {
PoolDataSource dataSource = PoolDataSourceFactory.getPoolDataSource();
dataSource.setUser("books");
dataSource.setPassword("books");
dataSource.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource");
dataSource.setURL("jdbc:oracle:thin:@//localhost:11521/ORCLPDB1");
dataSource.setFastConnectionFailoverEnabled(true);
dataSource.setInitialPoolSize(5);
dataSource.setMinPoolSize(5);
dataSource.setMaxPoolSize(10);
return dataSource;
}
}