My Oracle Support Banner

How to Set V$SESSION Properties Using the JDBC Thin Driver (Doc ID 147413.1)

Last updated on DECEMBER 08, 2020

Applies to:

JDBC - Version 9.2.0.1 and later
Information in this document applies to any platform.
***Checked for relevance on 15-May-2012***

Goal

This sample illustrates how to set V$SESSION properties upon connection using the JDBC Thin driver.
The sample queries the table to confirm that the property has been set.

Note: The JDBC Thin driver cannot correctly retrieve the values of some V$SESSION properties on its own. Specifically, the driver exhibits the following behavior:

  • When querying the TERMINAL field of the V$SESSION table using the JDBC Thin driver, the value returned is "unknown".
  • When querying the PROCESS field of the V$SESSION table using the JDBC Thin driver, the value returned is "1234". The driver returns the process ID as "1234" by default, since obtaining a process ID is not possible using the JDBC Thin driver.

Therefore, for an appropriate terminal name or process ID to be returned to the JDBC Thin driver, these properties may be populated using the method described below.

This specified example sets and queries the PROGRAM field of the V$SESSION table; the TERMINAL or PROCESS fields of this table can be set from this example by uncommenting the appropriate lines of code.

This same syntax can be used to set any field in the V$SESSION table.

The following method apply to the JDBC Thin driver; the JDBC OCI driver calculates some fields, such as PROGRAM and OSUSER, differently from the JDBC Thin driver.

Note: This method setting the values of properties such as V$SESSION.OSUSER, and other V$SESSION properties, involves no validation or authentication. This approach should not be used as part of any security framework, since it can be used to set these properties to arbitrary values.

 

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution
References

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.