How do I change the username / password of a data source at runtime in a Java EE application?

I have deployed a web module that connects to a database through a datasource configured on a Java EE application server.

Currently, the user / password for connecting to the database is set in the configuration file of the Java EE Application Server data files.

I want to change the user / password of the data source at runtime. (for example: implement a new web form where the user is prompted for a user / password to be used in connection with the database).

Is there a standard way to do this in Java EE applications, or does it depend on the Java EE application server? In this case, I am using the Orion app server .

+2


a source to share


2 answers


The DataSource has a getConnection method that uses a username and password. This is similar to what you are looking for.



+3


a source


Data source management is not standardized. You should use your AS API if it provides a slightly unusual use case for this.



0


a source







All Articles