-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Does a connection gets locked when it is used for a session
PostPosted: Wed May 28, 2014 3:39 am 
Newbie

Joined: Wed May 28, 2014 3:31 am
Posts: 1
A dba in my office proposed the following to audit db access (oracle):
Put the current logged in user in my application as a property on the db connection (java.sql.Connection).

Code:
public class ClientInfoProvider {
    void enrichConnection(Connection connection, String userName)  throws SQLException  {
        OracleConnection oConn = (OracleConnection) connection;
            String[] metrics = new String[OracleConnection.END_TO_END_STATE_INDEX_MAX];
            metrics[OracleConnection.END_TO_END_CLIENTID_INDEX] = userName;
            oConn.setEndToEndMetrics(metrics, (short) 0);
    }
}

public class AuditableDataSource implements DataSource {
...
    @Override
    public Connection getConnection() throws SQLException {
        Connection connection = dataSource.getConnection();
        clientInfoProvider.enrichConnection(connection, userName);
        return connection;
    }
...
}


My main concern is that connections are pooled. Wil users not end up using the same connection? The last user which changes the properties of the connection might influence the other users that are already using this connection. Is this a correct assumption?

Does a connection gets locked when it is used for a single session?
In the docs I can find that a connection is released by a session once it end, but not that one session locks the connection for private use while the session is running.

Thanks for the insights!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.