When an java app connects to oracle depending on the driver such as osuser, program in v$session will not be set (i.e. will be NULL) in Oracle. This issue is fixed in 10.2.0.4 oracle JDBC driver which can be downloaded from the following URL (http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html).
Another workaround this issue is to pass the value in java.util.Properties when establishing the connection.
(This workaround fix depends on the driver being used so it may not work in all situations).
java.util.Properties props = new java.util.Properties();
Connection conn = DriverManager.getConnection(“jdbc:oracle:thin:scott/tiger@host:1521:TESTSID”, props);
In a separate window, during the execution of the program one can see the value of osuser and program is set.
SELECT osuser, program from V$session