commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dgra...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool KeyedCPDSConnectionFactory.java
Date Wed, 09 Apr 2003 00:33:36 GMT
dgraham     2003/04/08 17:33:36

  Modified:    dbcp/src/java/org/apache/commons/dbcp/jdbc2pool
                        KeyedCPDSConnectionFactory.java
  Log:
  Fixed exception handling for PR# 18834.
  
  Revision  Changes    Path
  1.6       +25 -25    jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/KeyedCPDSConnectionFactory.java
  
  Index: KeyedCPDSConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/KeyedCPDSConnectionFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- KeyedCPDSConnectionFactory.java	2 Apr 2003 00:48:49 -0000	1.5
  +++ KeyedCPDSConnectionFactory.java	9 Apr 2003 00:33:36 -0000	1.6
  @@ -7,7 +7,7 @@
    *
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 1999-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -150,32 +150,32 @@
           return _pool;
       }
   
  -    synchronized public Object makeObject(Object key) {
  +    /**
  +     * @param key
  +     * @throws SQLException if the connection could not be created.
  +     * @see org.apache.commons.pool.KeyedPoolableObjectFactory#makeObject(java.lang.Object)
  +     */
  +    public synchronized Object makeObject(Object key) throws Exception {
           Object obj = null;
           UserPassKey upkey = (UserPassKey)key;
  -        try
  +
  +        PooledConnection pc = null;
  +        String username = upkey.getUsername();
  +        String password = upkey.getPassword();
  +        if ( username == null ) 
           {
  -            PooledConnection pc = null;
  -            String username = upkey.getUsername();
  -            String password = upkey.getPassword();
  -            if ( username == null ) 
  -            {
  -                pc = _cpds.getPooledConnection();
  -            }
  -            else 
  -            {
  -                pc = _cpds.getPooledConnection(username, password);
  -            }
  -            // should we add this object as a listener or the pool.
  -            // consider the validateObject method in decision
  -            pc.addConnectionEventListener(this);
  -            obj = new PooledConnectionAndInfo(pc, username, password);
  -            pcMap.put(pc, obj);
  +            pc = _cpds.getPooledConnection();
           }
  -        catch (SQLException e)
  +        else 
           {
  -            throw new RuntimeException(e.getMessage());
  +            pc = _cpds.getPooledConnection(username, password);
           }
  +        // should we add this object as a listener or the pool.
  +        // consider the validateObject method in decision
  +        pc.addConnectionEventListener(this);
  +        obj = new PooledConnectionAndInfo(pc, username, password);
  +        pcMap.put(pc, obj);
  + 
           return obj;
       }
   
  
  
  

---------------------------------------------------------------------
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