How database transactions are recovered
When the Liberty 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 the server.xml configuration file. You can assign a unique identifier or a jndiName attribute for the data source as follows:
<dataSource id="ds1" jndiName="jdbc/ds1"... />
You 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 you change any other attributes of the dataSource element, those changes are retained for the recovery. Therefore, you can, for example, add a recoveryAuthDataRef attribute that specifies a database user ID and password to use for recovery.
- 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" .../>
- 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, you have the
following code:
<resource-ref name="jdbc/ds1ref" binding-name="jdbc/ds1"> <authentication-alias name="user1Auth"/> </resource-ref>
- In the server.xml file, you must define the
following code:
<authData id="user1Auth" user="dbuser1" password="{xor}Oz0vKDtu"/> <dataSource id="ds1" jndiName="jdbc/ds1" jdbcDriverRef="DB2" .../>
- In the ibm-web-bnd.xml file, you have the
following code:
- 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>
- 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.