Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Alterar o identificador do Oracle JDBC Thin Client


[Idêntico a esta resposta]
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

No nível do aplicativo, você pode usar os seguintes métodos para definir client_info , módulo e ação em v$sessão :
dbms_application_info.set_client_info
dbms_application_info.set_module
dbms_application_info.set_action