Does anyone have examples of how to use DBMS_APPLICATION_INFO package with JBOSS?
We have a various applications which run within JBOSS and share db pools. I would like, at the start of each session these applications to identify themselves to the database using DBMS_APPLICATION_INFO so I can more easily track which sections of the application is causing database issues.
I'm not too familiar with session life cycles in JBOSS, but at the end of the day, what needs to happen is at the start and end of a transaction, this package needs to be called.
Has anyone done this before?
yes, you can write a wrapper class around your connection pool, and a wraper around the connection so lets say you have:
Change it to:
Note the use of WrappedOracleConnection above. You need this because you need to trap the close call
Hope this helps, I do something similar on a development server to catch connections that are not closed (not returned to the pool).
If you are using JBoss, you can use a "valid-connection-checker". This class is normaly used to check the validity of the Connection. But, as it will be invoked every time the Connection pool gives the user a Connection, you can use it to set the DBMS_ APPLICATION _INFO.
You declare such a class in the oracle-ds.xml like this:
Your class must implement the org.jboss.resource.adapter.jdbc.ValidConnectionChecker interface. If you use Maven, you can include this interface with the following dependency:
This interface has only one method: isValidConnection. I copy my implementation:
Hope it helps !
Benoît
In your -ds.xml, you can set a connection property called v$session.program and the value of that property will populate the PROGRAM column of each session in the V$SESSION view created for connections originating from your connection pool. I usually set it to the jboss.server.name property.
See here for an example.