Closed simeonmalchev closed 8 years ago
Just to clarify further on the previous comment, we said that the call to DataSource.getConnection(username, password) is a rarely used feature, as the majority of applications will typically call DataSource.getConnection() without parameters, and via this call they will obtain a connection form the pool which has been created with the configured default username and password.
Fixed in this commit. Implemented support for different usernames/passwords when calling getConnection with (username, password) credentials. If the supplied credentials are different than the configured defaults, a new non-pooled Connection will be created and returned. This prevents the risk that too many underlying connection pools can be created by Vibur DBCP, if it had to create a new pool for every different pair of username/password which is given to it by the application.
Different usernames and passwords are not supported yet and the call to
DataSource.getConnection(username, password)
will simply log a warning message and then will create and return a connection using the configured default username and password.Using different usernames and passwords for creating connections to a database (from one and the same application) is a rarely used feature, and implementing support for it will be considered based on users requests and demand.
Until then an obvious workaround will be to use different connection pools for the different usernames and passwords required, i.e. if the application needs a pair of different usernames and passwords for accessing the database, 2 different connection pools can be created and used by the application.