Re: Commons DBCP/Tomcat/Oracle RAC Questions



Using Oracle JDBC connection caching with Tomcat should not be
different than using it with a stand-alone Java/JDBC code.
In summary:

a)create an Oracle data source
OracleDataSource ods = new OracleDataSource();

b) set the DataSource property ConnectionCachingEnabled to true
ods.setConnectionCachingEnabled(True);

c) optionally set more properties (see the Oracle JDBC doc for more
details @
http://www.oracle.com/pls/db102/to_pdf?pathname=java.102%2Fb14355.pdf&remark=portal+%28Application+development%29
)
ods.setConnectionCacheName("MyCache"); // optional
ods.setConnectionCacheProperties(cp); // optional

d) getConnection() will service connection requests from the cache (you
may pre-populate the cache with minimal number of connections,
otherwise the first connection requests will trigger connection
creation).
conn = ods.getConnection();


For Fast Connection Failover in RAC environments using 10g JDBC:
1) you need to configure ONS so that JDBC can subscribe to RAC events
and be notified upon node/instance/service failure or the addition of
new instance.
2) Then, enable FastConnectionFailover either programmatically
ods.setFastConnectionFailoverEnabled(true);
or using system property: java -D
oracle.jdbc.FastConnectionFailover=true

3) catch fatal SQLEXception (and retry if so). fata SQLException is a
list of SQL exceptions related to node/instance/service/network down
(user can programmatically add it's own exceptions)

See codes samples @
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/oracle10g/index.html
See also complete step by step instructions in chapter 7 of my book @
http://www.amazon.com/gp/product/1555583296/

Kuassi, http://db360.blogspot.com/

.