30 ноября 2012 г.

oracle: JDBC Thin Client in v$session

Заметки о том как отображаются сессии от JDBC Thin Client в v$session

Если попытаться посмотреть информацию о JDBC Thin Client в v$session, то всегда v$session.process = 1234

SELECT s.program,s.process, s.sid, s.seq#, s.event
  FROM v$session s


JDBC Thin Client1234489429653db file sequential read


Почему так происходит, почему PID клиентского процесса в OS всегда 1234 в случае с JDBC Thin Client ?

Ответ:


How to Set V$SESSION Properties Using the JDBC Thin Driver [ID 147413.1]

Note: The JDBC 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.




Java developer can provide value in code (if code change is an option) using Java Properties when creating JDBC connection:
         prop.put("v$session.process", clientProcess);
         prop.put("v$session.program", programName);