How do I make my Java application identify itself to Oracle on connection?

前端 未结 5 1390
深忆病人
深忆病人 2020-12-24 09:33

When my application connects to an Oracle database I want to be able to see by looking at the active sessions in the database that it is connected. Currently it identifies i

5条回答
  •  心在旅途
    2020-12-24 09:50

    Since oracle jdbc 12.1 you can set some client-info values via jdbc api, i.e. you can do

    connection.setClientInfo("OCSID.CLIENTID", "MyClientId");
    

    for properties OCSID...

    ACTION, CLIENTID, ECID, MODULE, SEQUENCE_NUMBER and DBOP

    See https://docs.oracle.com/database/121/JJDBC/jdbcvers.htm#JJDBC29006

    Setting PROGRAM doesn't work this way, you can do that as described in the accepted answer or somewhat easier by setting the System property "oracle.jdbc.v$session.program".

提交回复
热议问题