Passing client information to a database
Use a WAS API or trace function, we can pass unique client information on every connection that originates from the same data source.
Some databases, such as DB2, support a data source custom property that triggers the database servers to extract client information from WAS connections. (Consult the database documentation to see whether your product supports this capability and which property WAS ND requires.) Be aware, however, that these properties introduce a very limited functionality in Application Server. Consequently, an application server connection manager incurs the following risky behaviors, which can result in the transfer of wrong client information to the database.
- The connection manager cannot change client information on the data source, or the connections obtained from that data source, dynamically.
- The connection manager must set the same client information on all connections that are obtained from that data source. For example, if we set ApplicationName as part of the data source clientInformation property, all connections from that data source have the same application name.
Application Server offers two methods of passing client information that provide the necessary connection management flexibility. Using either method, we can set client information on some connections and not others, as well as set different client information on different database connections from the same data source.
- Use the IBM proprietary setClientInformation(Properties) API.
The API is defined on the WSConnection class, which is part of the PLUGINS_ROOT/com.ibm.ws.runtime_6.1.0.jar file.
- Cast the connection objects in the applications to com.ibm.websphere.rsadapter.WSConnection before calling the API.
- Optionally, set a properties object for adding new client information on a connection if and when new information is introduced by the backend database:
public void setClientInformation (Properties props)throws SQLException;- We can also activate the function implicitly (that is, within Application Server) by using the WAS.clientinfo trace string. Enable this trace dynamically, from the admin console, just as you activate any other trace.
See about passing client information implicitly, see Implicitly set client information.
Results
Example
See Example: Setting client information with the setClientInformation(Properties) API.
Example: Setting client information with the setClientInformation(Properties) API
Implicitly set client information
Set client information traces with the admin console