Defining optimistic concurrency control for JDBC mediator

Implement an optimistic concurrency control (OCC) strategy for the Java™ Database Connectivity (JDBC) DMS to diagnose transaction problems that are caused by update collisions.

About this task

An update collision occurs when client data that populates a data graph is changed in the database before the data graph can submit the modifications of the client. If you configure the JDBC DMS for OCC, the DMS issues an OCC-specific exception when such a data collision happens. The OCC exception contains collision details such as the original row values, current row values, and the attempted row values. The client application uses these values to determine how to recover from the collision. For example, the application can reread the data and restart the transaction.

Be aware, however, that when one exception occurs, there is no way of knowing whether more exceptions exist deeper in the data graph schema and therefore are not displayed.

To activate OCC for the data mediator service, you must incorporate OCC columns into your database tables.

Add an OCC Integer column to a given table, and specify that this column is to be used for OCC in the metadata. The defined OCC collision column is reserved for the exclusive use of the mediator. If there is no OCC column defined for a table, the DMS does not monitor and notify you of update collisions. The following generic code segments create this setup.

Procedure

  1. Create the OCC column
    Column collisionColumn = table.addIntegerColumn("OCC_COUNT");
    
  2. Ensure that it does not allow null values
     collisionColumn.setNullable(false);
    
  3. Designate the column as the table collision column
     table.setCollisionColumn(collisionColumn);

    For a fully-fledged code example that forces a collision to demonstrate the OCC exception, see the topic Example: Forcing OCC data collisions and JDBC mediator exceptions.




In this information ...


Related concepts
Related reference

IBM Redbooks, demos, education, and more

(Index)

Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience.

This feature requires Internet access.

Task topic    

Terms of Use | Feedback

Last updated: Oct 21, 2010 5:30:17 AM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=compass&product=was-nd-iseries&topic=tdat_sdoocc
File name: tdat_sdoocc.html