开发者

How to change a datasource's username/password at runtime in a Java EE app?

开发者 https://www.devze.com 2022-12-29 15:01 出处:网络
I\'ve deployed a web-module which connects to the database via a datasource configured in the Java EE application server.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号