+

Search Tips   |   Advanced Search

How database transactions are recovered

When the Liberty profile transaction manager recovers indoubt database transactions, it uses either the unique identifier or the JNDI name to locate the current dataSource element, and then determines the user ID and password to use for recovery.

Configure a data source by specifying the attributes of the dataSource element in server.xml. We can assign a unique identifier or a jndiName attribute for the data source as follows:

We must not change the value of the id or jndiName attribute when a recovery is pending for a transaction in which the data source participated. If we change any other attributes of the dataSource element, those changes are retained for the recovery. Therefore, we can, for example, add a recoveryAuthDataRef attribute that specifies a database user ID and password to use for recovery.

The database user ID and password to use for recovery are determined according to the following order of precedence:

  1. If the dataSource element has the recoveryAuthDataRef attribute defined, then the user ID and password from the authData element are used. For example:
    <authData id="recoveryAuth" user="dbuser1" password="{xor}Oz0vKDtu"/>
    <dataSource id="ds1" jndiName="jdbc/ds1" jdbcDriverRef="DB2" 
                recoveryAuthDataRef="recoveryAuth" .../>

  2. If container-managed authentication is used, then the user ID and password from the container-managed authentication alias are used. For example:

    • In the ibm-web-bnd.xml file, we have the following code:
      <resource-ref name="jdbc/ds1ref" binding-name="jdbc/ds1">
          <authentication-alias name="user1Auth"/>
       </resource-ref>

    • In server.xml, we must define the following code:
      <authData id="user1Auth" user="dbuser1" password="{xor}Oz0vKDtu"/>
      <dataSource id="ds1" jndiName="jdbc/ds1" jdbcDriverRef="DB2" .../>

  3. The user ID and password from the dataSource element are used. For example:
    <dataSource id="ds1" jndiName="jdbc/ds1" jdbcDriverRef="DB2" ...>
         <properties.db2.jcc databaseName="testdb" user="dbuser1" password="{xor}Oz0vKDtu"/>
    </dataSource>

  4. If none of the previous conditions are satisfied, and the recovery is attempted without any user ID and password, then the behavior is determined by the JDBC driver and database.

If the transaction recovery is performed by an application-defined data source, such as an @DataSourceDefinition annotation or a <data-source> element in the deployment descriptor, we must ensure that the associated application is running when the recovery is taking place. We cannot use configuration settings in server.xml to recover application-defined data sources.


Parent topic: Administer the transaction service

Tasks:

  • Configure authentication aliases