Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
1.1, 1.2, 1.2.1, 1.2.2
-
None
-
Use of SharedPoolDataSource see sample code
if (privSharedDS == null)
{
privConPoolDS = new PGConnectionPoolDataSource();
privConPoolDS.setServerName(privServerName);
privConPoolDS.setDatabaseName(privServerDB);
privConPoolDS.setUser(privUser);
privConPoolDS.setPassword(privPassword);
// --------------------------------------
// dbcp caching via SharedPoolDataSource
// --------------------------------------
privSharedDS = new SharedPoolDataSource();
privSharedDS.setConnectionPoolDataSource(privConPoolDS);
privSharedDS.setMaxActive(10); // 0 = no limit
privSharedDS.setMaxIdle(10);
privSharedDS.setMinEvictableIdleTimeMillis(1000);
privSharedDS.setMaxWait(1000); // -1 = no limit
privSharedDS.setTimeBetweenEvictionRunsMillis(1000);
privSharedDS.setTestWhileIdle(true);
}
// --------------------------------------
// dbcp caching via SharedPoolDataSource
// --------------------------------------
tmpCon = privSharedDS.getConnection(privUser, privPassword);Use of SharedPoolDataSource see sample code if (privSharedDS == null) { privConPoolDS = new PGConnectionPoolDataSource(); privConPoolDS.setServerName(privServerName); privConPoolDS.setDatabaseName(privServerDB); privConPoolDS.setUser(privUser); privConPoolDS.setPassword(privPassword); // -------------------------------------- // dbcp caching via SharedPoolDataSource // -------------------------------------- privSharedDS = new SharedPoolDataSource(); privSharedDS.setConnectionPoolDataSource(privConPoolDS); privSharedDS.setMaxActive(10); // 0 = no limit privSharedDS.setMaxIdle(10); privSharedDS.setMinEvictableIdleTimeMillis(1000); privSharedDS.setMaxWait(1000); // -1 = no limit privSharedDS.setTimeBetweenEvictionRunsMillis(1000); privSharedDS.setTestWhileIdle(true); } // -------------------------------------- // dbcp caching via SharedPoolDataSource // -------------------------------------- tmpCon = privSharedDS.getConnection(privUser, privPassword);
Description
The SharedPoolDataSource saves wrong password forever
1. Get a connection for user1 (use username of user1 and password of user1) ---> connection ok
2. Get a connection for user2 (use username of user2 and a wrong password) --> connection failed
3. Get a connection for user2 (use username of user2 and password of user2) --> connection will be failed too because the wrong password is stored in the usersKey map.
Bugfix
===================================================================
protected synchronized PooledConnectionAndInfo
getPooledConnectionAndInfo(String username, String password)
throws SQLException {
if (pool == null) {
try
catch (NamingException e)
{ throw new SQLNestedException("RegisterPool failed", e); }}
PooledConnectionAndInfo info = null;
UserPassKey userPassKey = null;
try
catch (Exception e) {
if (userKeys != null && userKeys.containsKey(username))
{ userKeys.remove(username); } throw new SQLNestedException(
"Could not retrieve connection info from pool", e);
}
return info;
}