Database Reference
In-Depth Information
JDBC
There are two ways to set session attributes. The legacy way uses an Oracle extension, but the contemparary way is
based on the standard JDBC application programming interface. The contemporary way is available as of version 12.1
of the JDBC drivers provided by Oracle. Because it's based on the same protocol as the legacy way, it can also be used
with databases of versions 10.2, 11.1 and 11.2. Note that from version 12.1 onward, the legacy way is deprecated.
The Legacy Way
To set the client identifier, module name, and action name, you use the setEndToEndMetrics method provided by
the OracleConnection interface. No support is provided to set the client information. One or more attributes are
passed to the method with an array of strings. The position in the array, which is defined by the following constants,
determines which attribute is set:
END_TO_END_CLIENTID_INDEX
END_TO_END_MODULE_INDEX
END_TO_END_ACTION_INDEX
The following code snippet, which is an excerpt of the SessionAttributes.java file, shows how to define the
array containing the attributes and how to call the setEndToEndMetrics method:
metrics = new String[OracleConnection.END_TO_END_STATE_INDEX_MAX];
metrics[OracleConnection.END_TO_END_CLIENTID_INDEX] = "helicon.cha.trivadis.com";
metrics[OracleConnection.END_TO_END_MODULE_INDEX] = "SessionAttributes.java";
metrics[OracleConnection.END_TO_END_ACTION_INDEX] = "test session information";
((OracleConnection)connection).setEndToEndMetrics(metrics, (short)0);
The Contemporary Way
To set the client identifier, module name, and action name, you use the setClientInfo method provided by the
Connection interface. No support is provided to set the client information. The setClientInfo method takes as input
two String parameters: the name of an attribute and its value. You must specify the name as one of the following:
OCSID.CLIENTID
OCSID.MODULE
OCSID.ACTION
The following code snippet, which is an excerpt of the SessionAttributes12c.java file, shows how to set the
attributes through the setClientInfo method:
connection.setClientInfo("OCSID.CLIENTID", "helicon.cha.trivadis.com");
connection.setClientInfo("OCSID.MODULE", "SessionAttributes12c.java");
connection.setClientInfo("OCSID.ACTION", "test session information");
 
Search WWH ::




Custom Search