commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dirk Verbeeck <dirk.verbe...@pandora.be>
Subject Re: [DBCP] RC2 -- PerUserPoolDataSource Problem
Date Wed, 15 Oct 2003 20:20:31 GMT
The if statement is probably put there to group all unknown/unregisterd 
users into a global pool.
I added your testcase to the testsuite, but no asserts yet, maybe the 
behaviour is intended.

Dirk

Mike Hanafey wrote:

>There appears to be a problem with PerUserPoolDataSource. For all usernames not
>set with "setPerUserMaxActive", the first "getConnection(String, String)
>sets the username under which all subsequent connections are created.
>
>For example, in the fragment below connections are gotten under the usernames
>{"mkh", "hanafey", "jsmith"}, but only "jsmith" has an associated
>"setPerUserMaxActive". The first two connections are BOTH created under
>username "mkh". (The "getUsername" method below just runs a query that selects
>the username, which in Sybase is just "select username=suser_name()")
>
>This is the output:
>
>Tried:mkh got:mkh
>Tried:hanafey got:mkh
>Tried:jsmith got:jsmith
>
>If "mkh" and "jsmith" are permuted, the output is:
>
>Tried:jsmith got:jsmith
>Tried:hanafey got:hanafey
>Tried:mkh got:hanafey
>
>
>This is the code fragment:
>
>        PerUserPoolDataSource puds = new PerUserPoolDataSource();
>        puds.setConnectionPoolDataSource(ds);
>        puds.setPerUserMaxActive("jsmith", new Integer(2));
>        try {
>            String[] users = {"mkh", "hanafey", "jsmith"};
>            String pw = "...";
>            Connection[] c = new Connection[users.length];
>            for (int i = 0; i < users.length; i++) {
>                c[i] = puds.getConnection(users[i], pw);
>            }
>            for (int i = 0; i < users.length; i++) {
>                System.out.println("Tried:"+users[i]+" got:"+getUsername(c[i]));
>            }
>        
>Given this code from PerUserPoolDataSource, the "if" statement explains the
>behaviour, given that data source name and username determine the subpool:
>
>    private PoolKey getPoolKey(String username) {
>        PoolKey key = null;
>
>        if (username != null && (perUserMaxActive == null 
>                || !perUserMaxActive.containsKey(username))) {
>            username = null;
>        }
>
>It appears that this "if" should just be removed.
>
>
>+-------------------------------------------------+
>|  Mike Hanafey                                   |
>|  DuPont Crop Genetics                           |
>|  Delaware Technology Park, Suite 200/206        |
>|  ----------------------+----------------------- |
>|  FedEx, UPS, etc.      |  US Mail               |
>|  ----------------      |  -------               |
>|  1 Innovation Way      |  POB 6104              |
>|  Newark, DE 19711-5490 |  Newark, DE 19714-6104 |
>|  ----------------------+----------------------- |
>|  Phone: (302)631-2608 Fax: (302)631-2607        |
>|  Email: hanafey@dna.es.dupont.com               |
>+-------------------------------------------------+
>  
>




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message