Reputation: 235
Our Java application (web application that runs on Jetty 7.5.4) uses an underlying database. There are multiple databases users and the Java part needs to access the DB using those database users. Am wondering if there is a database connection pool library that lets us access the DB with multiple database users. I know there are a bunch of dbcp libraries that lets us use with single database user, but am unable to find any library that supports multiple database users.
Any help is appreciated, Thanks, Pram.
Upvotes: 6
Views: 1149
Reputation: 176
In addition to ngreen's comment above, you also need to set AlternateUsernameAllowed to true in your data source properties, however you still need to set a username / password on the properties as this is used when the pool is created.
/**
* Returns true if the call {@link DataSource#getConnection(String, String) getConnection(username,password)} is
* allowed. This is used for when the pool is used by an application accessing multiple schemas.
* There is a performance impact turning this option on.
* @return true if {@link DataSource#getConnection(String, String) getConnection(username,password)} is honored, false if it is ignored.
*/
public boolean isAlternateUsernameAllowed();
Upvotes: 2
Reputation: 1769
Tomcat DBCP definitely supports multiple users (source code). I'm not exactly sure how to configure it, but it has implemented DataSource.getConnection(username, password)
, which is the key feature needed.
Upvotes: 3