I'm working in a CMP project on IBM WebSphere App. Server and WebSphere Studio App. Developer.
As you know when we work with CMP beans the container manage all resources including datasource connections, but in order to maintain my security profile (you know.. client requirements...!!), I need to specify different values for datasource's username and password.
(each user will connect with his own database username and password. It can't be a generic database user)
Is possible change the datasource parameters in run time to my CMP container ? or it only works with the values that I set it in the general container configuration.
thanks in advance
Have you tried not defining the username and password in the configuration, and instead having the app use the getConnection(String username, String password) method?
I think that you wrote me about a code like this:
DatabaseResources dbResources = DatabaseResources.getInstance() ;
DataSource dataSource = dbResources.getDataSource() ;
connection = dataSource.getConnection( userID, password ) ;
but, did you used this code with CMP beans ?
thanks for advise me
Can't use this type of code with a CMP. The container is responsible for obtaining and managing the data source connection. To utilize this style of programming you need to switch to a BMP.
Why can't you allow the container to utilize a generic connection and configure the EJB's security to identify individual users?
Admittedly I haven't tesed this at all, but I was thinking more along the lines of having the bean get a new connection...perhaps something like:
InitialContext ctx = new InitialContext();
DataSource dataSource = (DataSource)ctx.lookup(jndiName);
Connection con = dataSource.getConnection(username, password);
// use the connection