Re: Oracle V$Session Question

From: Guenter Nowak <guenter.nowak_at_gmx.at>
Date: 14 Jan 2003 01:37:42 -0800
Message-ID: <75b726d3.0301140137.298c31ac_at_posting.google.com>


"Rob Panosh" <rob_panosh_at_asdsoftware.com> wrote in message news:<3e1d767c$1_at_nntp01.splitrock.net>...
> Hello,
>
> When my application connects to the database using ADO "Oracle Provider for
> OLE DB" and I query V$Session WHERE shemaname = 'MYSCHEMA' the column
> Program show my program name "ProvisApp.Exe". Is the configurable when I
> connect to the database. I want to be able to change this value to be
> 'Rob - ProductVision'.
>
> Any help would be appreciated.
>
> TIA,
> Rob Panosh

hi

from metalink.oracle.com
Note:1022663.6
Subject: HOW THE PROGRAM COLUMN OF THE V$SESSION TABLE IS POPULATED

Problem Description:



You are interested in knowning how the PROGRAM column of the V$SESSION table
is populated.
***Note: This is the same column used to display the Program Name information
in the Session Manager program under Windows. Search words: NT, 95, EXECUTABLE, PROCESS Solution Description:

The PROGRAM value is actually obtained by the Oracle interface library. This
is typically ORA??WIN.DLL or ORA??.DLL under the MS-Windows platforms. The
library takes advantage of the fact that it is loaded into the calling programs address space at runtime and therefore has access to the programs
startup information. The following are the WinAPI calls used by the interface
library to feed the V$SESSION table's PROGRAM column. 32bit SQL*Net:

WinAPI call used -- GetStartupInfo()
***Note : Uses the 'lpTitle' member from the STARTUPINFO structure parameter
to populate the PROGRAM column.
16bit SQL*Net:

WinAPI call used -- GetModuleFileName() ***Note: Uses the 'lpFilename' parameter to populate the PROGRAM column.

from metalink.oracle.com
Note:147413.1
Subject: Example: How to set V$SESSION Properties Using the JDBC Thin Driver (SCR 1463)

Overview


 

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. This specified example sets and queries the
PROGRAM field of the V$SESSION table.  

Program Notes


 

  o This code connects as user SCOTT. When connecting as another user,

     ensure that you have the necessary privileges to view the V$SESSION
     table.  

  o Code was tested using the Oracle 8.1.7 JDBC Thin driver against the

     8.1.7 RDBMS, using the 1.2 JDK on Windows 2000 SR 1.  

  o Because the functionality illustrated in this sample is specific to Java,

     it is applicable only to the JDBC Thin driver, not the OCI driver or any

     other programmatic interface.  For other programmatic interfaces,
     consider the use of built in packages such as
DBMS_APPLICATION_INFO.   References
 

Information in this article was taken from Oracle Sample Code Repository
Entry #1463.  

Caution


 

The sample program in this article is provided for educational purposes only
and is NOT supported by Oracle Support Services. It has been tested internally, however, and works as documented. We do not guarantee that it
will work for you, so be sure to test it in your environment before relying
on it.    

Program


 
  • - - - - - - - - - - - - - - - Code begins here - - - - - - - - - - - - - - - -
/* 
 * This sample shows how to set V$SESSION values upon 
 * connection using the JDBC Thin drdiver.  This sample 
 * specifically illustrates setting the PROGRAM property of the 
 * V$SESSION table.  The sample then queries the PROGRAM 
 * field to verify that the field has been set as specified. 
 * 
 * The same syntax can be used to set any field in the V$SESSION 
 * table. 
 */ 
 

// Import the java.sql package
import java.sql.*;  

class SessionProps
{
  public static void main (String args [])

       throws SQLException
  {
    // Load the Oracle JDBC driver
    DriverManager.registerDriver(new
oracle.jdbc.driver.OracleDriver());  

    java.util.Properties props = new java.util.Properties();     props.put("v$session.program", "My program!");  

    // Connect to the database
    Connection conn =
      DriverManager.getConnection
("jdbc:oracle:thin:scott/tiger_at_mslangorl:1821:V817",

                                   props);  

    // Create a Statement
    Statement stmt = conn.createStatement ();  

    // Select the PROGRAM field from the V$SESSION table     ResultSet rset = stmt.executeQuery ("select program from v$session");  

    // Iterate through the result
    while (rset.next ())
      System.out.println (rset.getString (1));   }
}    

  • - - - - - - - - - - - - - - - Code ends here - - - - - - - - - - - - - - - -

Sample Output


 
ORACLE.EXE 
ORACLE.EXE 
ORACLE.EXE 

Sqlplusw.exe
null
My program! Received on Tue Jan 14 2003 - 10:37:42 CET

Original text of this message