How to change a datasource's username/password at runtime in a Java EE app?
I've deployed a web-module which connects to the database via a datasource configured in the Java EE application server.
Currently, the user/password for the database connection is set in the proper Java EE application server's dataso开发者_StackOverflow社区urces configuration file.
I want to change during runtime the datasource's user/password. (e.g.: implement a new web form in which the user is asked to enter de user/password to be used in the database connection).
Is there a standard way to do that in Java EE applications or it depends on the Java EE application server? In this case I'm using Orion application server.
DataSource has a getConnection method that takes a username and password. That seems to be what you are looking for.
The management of data sources is not standardized. You have to use your AS' API, if it provides any for this a bit unusual use case.
精彩评论