Configuring Two-Phase Commit

To access more than one Oracle database in the same transaction, you need to enable two-phase commit by configuring a commit coordinator database and linking it to each of the other databases involved, as described here:

  1. Choose a database to act as the commit coordinator. This can be any of the databases involved in the transaction, or a separate database.

  2. Using your favorite Oracle client, create database links from the commit coordinator database to the other databases. For example, the following commands create links to the "product" and "inventory" databases:

     create database link productlink using "product"; create database link inventorylink using "inventory"; 
  3. Configure the two-phase commit coordinator by adding the following to OC4J_HOME/j2ee/home/config/application.xml (substituting the appropriate username and password):

     <commit-coordinator>     <commit-class class="com.evermind.server.OracleTwoPhaseCommitDriver" />     <property name="datasource" value="jdbc/OracleCommitDS /> </commit-coordinator> 
  4. Edit data-sources.xml to add a data source called OracleCommitDS (referenced in your commit-coordinator element). This data source should point to the database that will act as the transaction commit coordinator, for example:

     <data-source         class=" com.evermind.sql.OrionCMTDataSource "         name="OracleCommitDS"         location="jdbc/ OracleCommitDS "         connection-driver="oracle.jdbc.driver.OracleDriver"         username="system"         password="manager"         url="jdbc:oracle:thin:@someserver:5521:somesid"         inactivity-timeout="30" /> 
  5. Define at least two regular data sources that should be able to participate in distributed transactions. Each of these data sources needs to use the OrionCMTDataSource implementation, and needs to specify a dblink property with the name of the corresponding database link that you created in step 2, as follows :

     <data-source         class=" com.evermind.sql.OrionCMTDataSource "         name="ProductDS"         location="jdbc/ ProductDS"         connection-driver="oracle.jdbc.driver.OracleDriver"         username="scott"         password="tiger"         url="jdbc:oracle:thin:@someserver:5521:product"         inactivity-timeout="30"         <property name="dblink" value="productlink.commitdb.acme.com" /> <data-source         class=" com.evermind.sql.OrionCMTDataSource "         name="ProductDS"         location="jdbc/InventoryDS"         connection-driver="oracle.jdbc.driver.OracleDriver"         username="scott"         password="tiger"         url="jdbc:oracle:thin:@someserver:5521:inventory"         inactivity-timeout="30"         <property name="dblink" value="inventorylink.commitdb.acme.com" /> 
  6. Use the data sources normally.



Oracle Application Server 10g. J2EE Deployment and Administration
Oracle Application Server 10g: J2EE Deployment and Administration
ISBN: 1590592352
EAN: 2147483647
Year: 2004
Pages: 150

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net