WAS v8.5 > Develop applications > Develop data access resources > Develop data access applications > Develop data access applications > Data access with Service DataObjects, API versions 1.0 and 2.01 > Java DataBase Connectivity Mediator Service

Define optimistic concurrency control for JDBC Mediator

Implement an optimistic concurrency control (OCC) strategy for the JDBC DMS to diagnose transaction problems that are caused by update collisions. 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 the 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.

  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.


Related concepts:

Concurrency control


Reference:

JDBC mediator exceptions


+

Search Tips   |   Advanced Search