Oracle – JDBC v$session osuser/program issue

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();

props.put(“v$session.program”, “testprogram”);
props.put(“v$session.osuser”,”Mike”);
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
OSUSER PROGRAM
————————- —————————
Mike testprogram

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s