1

I have here an application that allows multiple user to connect via it to database. For auditing purpose the value of osuser must be stored.

For a new connection it is easy to add a value:

Properties prop = new Properties();
props.setProperty(oracle.jdbc.OracleConnection.CONNECTION_PROPERTY_THIS_VSESSION_OSUSER, "Apple");
Connection con = DriverManager.getConnection("jdbc:.....", props);

But is it also in some way possible to change it for an already established connection?

I would prefer to avoid connecting to the backend every time a customer requests some data.

My ideal solution would be to have a pool of, say, 10 connections for which in case customer is doing something I intercept the request, set osuser to his user, do some SQL, then release the connection reseting again the customer osuser, so I can reuse it next time.

Any ideas?

Thanks!

6
  • osuser should identify the OS owner of the client processes on the client computer - not the application end user. This is especially true for 2- or 3-tier application server situations where the OS user is typically a service account of some kind. It should never be changed in mid-session. If you need to identify the end-user through the application, within the database, use the DBMS_APPLICATION_INFO or DBMS_SESSION packages to set session or application context attributes for auditing. Commented May 19, 2023 at 14:28
  • Sorry, but this is not an answer to my question. To use osuser is not a decision by me, but the entire concept of data storage/identification of user was decided many years ago, so for sure it will not be chang ed because I suddenly come with different idea. I have to live with it as it is. So please stuck to my question only. Commented May 19, 2023 at 16:44
  • 1
    I was not attempting to answer your question directly, because it has no answer. As far as I know this is not a property that can be changed once a connection is established, because it was never intended to be used for this purpose. By using osuser for a in this way, you are actually losing valuable auditing data. Having to reconnect isn't just inconvenient, it also isn't performant or scalable: it defeats the entire purpose of having a connection pool. The appropriate tools for the need you described are the PL/SQL packages I mentioned. Commented May 19, 2023 at 19:14
  • I appreciate that you may not have any ability to drive change here, but the fact that this decision was made years ago doesn't make it any less wrong, in my opinion. Commented May 19, 2023 at 19:16
  • Thank you, this is a answer I was looking for. If it is not possible to change it for established connection, then we have to live with it and search for another solution. This osuser approach may really not be the best idea, I agree, but there is a lot of logic already implemented based on it. As external customer we have to accept it, we like it or not. We must therefore look how we can deal with it now... Commented May 20, 2023 at 17:31

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.