Change Oracle JDBC Thin Client Identifier

前端 未结 2 707
南方客
南方客 2021-02-02 13:32

When connecting to Oracle the JDBC driver identifies itself as \"JDBC Thin Client\" to Oracle (in v$session as the \'program\'). There is also a \'ClientInfo\' column in v$sessi

相关标签:
2条回答
  • 2021-02-02 14:11

    There is also an Oracle function:

    dbms_application_info.set_client_info('Client Info'); 
    

    which sets the ClientInfo column in v$session.

    0 讨论(0)
  • 2021-02-02 14:28

    [Identical to this answer]

    java.util.Properties props = new java.util.Properties();
    props.setProperty("password","mypassword");
    props.setProperty("user","myusername");
    props.put("v$session.osuser", System.getProperty("user.name").toString());
    props.put("v$session.machine", InetAddress.getLocalHost().getCanonicalHostName());
    props.put("v$session.program", "My Program Name");
    DriverManager.registerDriver (new oracle.jdbc.OracleDriver());
    Connection conn=
        DriverManager.getConnection("jdbc:oracle:thin:@myhostname:1521:mysid", props);
    

    SQL>select username,osuser,program,machine
    from v$session
    where username = 'ROB'; 
    
    USERNAME  OSUSER       PROGRAM             MACHINE
    --------- -----------  ------------------  -----------
    ROB       rmerkw       My Program Name     machine
    

    At application level you can use the following methods to set client_info, module and action in v$session:

    dbms_application_info.set_client_info
    dbms_application_info.set_module
    dbms_application_info.set_action
    
    0 讨论(0)
提交回复
热议问题