I've got a simple task to complete, but I don't know what's the easiest method to pass.

Each user has their very own account information for connecting to some database with various privilege. When the user connect, he is going to do multiple query base on which action he wish to perform. Therefore I wish to support the reference to the database. Here is my question?

Is it more beneficial to attain things i want related to connection pooling or session or both? Sample code could be appreciated!!! thanks greatly.

Define a container handled connection put DataSource with "root" rights within the server as well as for each user take advantage from the [cde] method that takes an account information as arguments.

I faced exactly the same problem by having an Oracle DB, where every transaction needs to be record for possible audits. So, whenever a user authenticates within the web application, it puts an item such as this:

DataSource#getConnection()

I Quickly implemented an association pool (with different Map) where the bottom line is the ConnectionUser object and also the value may be the open connection. When the key does not appear in the map, it produces an association and allocates it in to the map.

I really hope it will help you.