Configuring FAN for Java Clients Using Universal Connection Pool
Oracle recommends that you use the Universal Connection Pool (UCP) or WebLogic Server Active GridLink to take full advantage of Fast Connection Failover (FCF) with the database JDBC Thin Driver.
To enable Fast Connection Failover (FCF), set the UCP pool property FastConnectionFailoverEnabled on the Universal Connection Pool. You do not need to configure this property for Active GridLink, because it enables FCF by default. Third-party application servers, including IBM WebSphere and Apache Tomcat, support UCP as a connection pool replacement.
To learn how to embed UCP with other web servers, refer to the following technical briefs:
- Design and deploy WebSphere applications for planned or unplanned database downtimes and runtime load balancing with UCP ( https://www.oracle.com/docs/tech/database/planned-unplanned-rlb-ucp-websphere.pdf )
- Design and deploy Tomcat applications for planned or unplanned database downtimes and Runtime Load Balancing with UCP ( https://www.oracle.com/docs/tech/database/planned-unplanned-rlb-ucp-tomcat.pdf )
Follow these configuration steps to enable Fast Connection Failover.
- Use the service name syntax for the connection URL. Oracle recommends that you specify a dynamic database service name, using the appropriate JDBC URL structure.
Ensure your URL format supports high availability. You can use either a Java Thin driver (JDBC Thin), or use an Oracle JDBC OCI driver.
If wallet authentication has not been established, then you must set up remote ONS configuration.
Set the pool property
setONSConfigurationin a property file. The property file must contain anons.nodesproperty. You also have the option to set properties fororacle.ons.walletfileandoracle.ons.walletpassword.The following is an example of an
ons.propertiesfile:PoolDataSource pds = PoolDataSourceFactory.getPoolDataSource(); pds.setConnectionPoolName("FCFSamplePool"); pds.setFastConnectionFailoverEnabled(true); pds.setONSConfiguration("propertiesfile=/usr/ons/ons.properties"); pds.setConnectionFactoryClassName("oracle.jdbc.pool.OracleDataSource"); pds.setURL("jdbc:oracle:thin@((CONNECT_TIMEOUT=4)(RETRY_COUNT=30)(RETRY_DELAY=3) "+ " (ADDRESS_LIST = "+ " (LOAD_BALANCE=on) "+ " ( ADDRESS = (PROTOCOL = TCP)(HOST=GSM1)(PORT=1522))) "+ " (ADDRESS_LIST = "+ " (LOAD_BALANCE=on) "+ "( ADDRESS = (PROTOCOL = TCP)(HOST=GSM2)(PORT=1522)))"+ "(CONNECT_DATA=(SERVICE_NAME=service_name)))");- Ensure that the pool property
setFastConnectionFailoverEnabled=trueis set. - Ensure that the
CLASSPATHincludesons.jar,ucp.jar, and the JDBC driver JAR file, such asojdbc8.jar. - If you use JDBC Thin with your database, then you can configure Application Continuity to fail over the connections after the FAN event.
- If your database requires custom ONS endpoints instead of the default autoconfiguration, then enable the appropriate ONS endpoints manually.
If multiple clusters exist with
auto-onsenabled, thenauto-onsgenerates node lists using the following rule:By default,
oracle.ons.maxconnectionsis set to 3 for every active node list. Typically, you do not need to set this value explicitly, or change this value. In this example, the ONS client tries to maintain six connections in total.
Related Topics
Parent topic: Application Development Considerations