Skip Headers

# Using Java

Previous

Next

The `SessionEvent.PostAcquireExclusiveConnection` event listener is your opportunity to authenticate your user and interact with the underlying database platform: for example, to execute PL/SQL to create VPD packages and set VPD context information.

Example: Session Event Listener for an Isolated Session illustrates a typical session event listener used to handle `postAcquireExclusiveConnection` events for an isolated session.

Session Event Listener for an Isolated Session

    class VPDEventListener extends SessionEventAdaptor{
        public void postAcquireExclusiveConnection(SessionEvent event){
            ClientSession session = (ClientSession)event.getSession();
            // Get property set on the ConnectionPolicy prior to acquiring the connection
            String userLevel = session.getConnectionPolicy().getProperty("userLevel");
            // Make the Stored Procedure call for VPD to set up the Context Information
            session.executeNonSelectingSQL("StoreProcSetContextUser("+ userLevel + ")");
        }
    }

To get the required user credentials, use `ClientSession` method `getConnectionPolicy` to get the associated `ConnectionPolicy`, and then use `ConnectionPolicy` method `getProperty`. The `ConnectionPolicy` associated with the `ClientSession` should contain all required user credentials (see "Configuring Connection Policy").

After you implement the required `SessionEventListener`, add it to the parent server session from which you acquire your isolated client session. For more information, see "Configuring Session Event Listeners".