Monday, 22 March 2010

Universal Connection Pool (UCP) with OC4J 10.1.3.x

I setup a native OC4J 10.1.3.x Data Source using the Oracle UCP and allthough I didn't really do much more then that it did work. Personally I would stick with ICC in OC4J 10.1.3.x and the default pool implementation but if you have a pressing need to use UCP this would work.

Note: This demo is based on using stand alone OC4J so the container in this case is known as "home"

1. Ensure that the container or stand alone OC4J is using the 11.1.0.7 JDBC driver. I created a shared library as follows which automatically use the latest version. For some reason the 10.1.0.5 default driver won't work here.

Name: oracle.jdbc
Version: 11.1.0.7


2. I wanted to test my data source from asconsole so to do that I needed to edit the $ORACLE_HOME\j2ee\home\application-deployments\ascontrol\orion-application.xml file of the deployed ascontrol application, and comment out the line that removes the importing of the global.libraries.xml file, as shown below.


<imported-shared-libraries>
<!--
<remove-inherited name="global.libraries"/>
-->

<import-shared-library name="oracle.xml.security"/>
</imported-shared-libraries>

3. Create a native Data Source as follows in your data-sources file.

<native-data-source
name="jdbc/UcpNativeDS"
jndi-name="jdbc/UcpNativeDS"
description="UCP Native DataSource"
data-source-class="oracle.ucp.jdbc.PoolDataSourceImpl"
user="scott"
password="tiger"
url="jdbc:oracle:thin:@beast.au.oracle.com:1522:linux10g">
<property name="connectionFactoryClassName"
value="oracle.jdbc.pool.OracleDataSource"/>
<property name="connectionPoolName" value="TestPool"/>
<property name="initialPoolSize" value="1"/>
<property name="maxPoolSize" value="20"/>
</native-data-source>
4. Copy ucp.jar , version 11.1.0.7, into $ORACLE_HOME/j2ee/home/applib of the container.

5. Stop/Start OC4J

6. Test the Data Source from asconsole as follows, which should then work for J2EE applications as well.



5 comments:

Yeu Wen Mak said...

Have you tried defining a managed data source rather than a native data source as your above example has shown?

Pas Apicella said...

You can't use a managed data source that is specifically for ICC (Implicit Connection Cache), so the only way to use UCP is as shown in this entry with OC4J 10.1.3.x.

Yeu Wen Mak said...

The reason I am looking into UCP is due to its supposedly better support for XA, and (FCF and RAC DB) integration. Without UCP, we are now using FCF with no XA. Since managed data source is required for a DB connection to participate in global transactions and UCP can only work with native data source (as you have kindly pointed out), I am basically back to square one unless we upgrade to OAS 11g (weblogic), yes?

Pas Apicella said...

Well for FMW 11g (WLS) it currently doesn't support UCP so not sure FMW 11g will do what you need here either.

Anonymous said...

Great read! You should definitely follow up to this topic!?