commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From di...@apache.org
Subject cvs commit: jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool CPDSConnectionFactory.java Jdbc2PoolDataSource.java KeyedCPDSConnectionFactory.java
Date Mon, 11 Aug 2003 16:02:10 GMT
dirkv       2003/08/11 09:02:10

  Modified:    dbcp/src/java/org/apache/commons/dbcp/jdbc2pool
                        CPDSConnectionFactory.java Jdbc2PoolDataSource.java
                        KeyedCPDSConnectionFactory.java
  Log:
  use SQLNestedException for improved error messages
  
  Revision  Changes    Path
  1.7       +8 -9      jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/CPDSConnectionFactory.java
  
  Index: CPDSConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/CPDSConnectionFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CPDSConnectionFactory.java	29 Jun 2003 12:42:16 -0000	1.6
  +++ CPDSConnectionFactory.java	11 Aug 2003 16:02:10 -0000	1.7
  @@ -74,6 +74,7 @@
   import javax.sql.ConnectionPoolDataSource;
   import javax.sql.PooledConnection;
   
  +import org.apache.commons.dbcp.SQLNestedException;
   import org.apache.commons.pool.ObjectPool;
   import org.apache.commons.pool.PoolableObjectFactory;
   
  @@ -155,12 +156,10 @@
           if (null != _pool && pool != _pool) {
               try {
                   _pool.close();
  +            } catch (RuntimeException e) {
  +                throw e;
               } catch (Exception e) {
  -                if (e instanceof RuntimeException) {
  -                    throw (RuntimeException) e;
  -                } else {
  -                    throw new SQLException(e.getMessage());
  -                }
  +                throw new SQLNestedException("Cannot set the pool on this factory", e);
               }
           }
           _pool = pool;
  
  
  
  1.15      +7 -7      jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/Jdbc2PoolDataSource.java
  
  Index: Jdbc2PoolDataSource.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/dbcp/src/java/org/apache/commons/dbcp/jdbc2pool/Jdbc2PoolDataSource.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Jdbc2PoolDataSource.java	11 Aug 2003 14:08:39 -0000	1.14
  +++ Jdbc2PoolDataSource.java	11 Aug 2003 16:02:10 -0000	1.15
  @@ -86,6 +86,7 @@
   
   import org.apache.commons.collections.FastHashMap;
   import org.apache.commons.collections.LRUMap;
  +import org.apache.commons.dbcp.SQLNestedException;
   import org.apache.commons.pool.KeyedObjectPool;
   import org.apache.commons.pool.ObjectPool;
   import org.apache.commons.pool.impl.GenericKeyedObjectPool;
  @@ -959,8 +960,7 @@
                   registerPool(username, password);
                   pool = pools.get(key);
               } catch (NamingException e) {
  -                e.printStackTrace();
  -                throw new SQLException(e.getMessage());
  +                throw new SQLNestedException("RegisterPool failed", e);
               }
           }
   
  @@ -971,7 +971,7 @@
                       ((ObjectPool) pool).borrowObject();
               } catch (NoSuchElementException e) {
                   closeDueToException(info);
  -                throw new SQLException(e.getMessage());
  +                throw new SQLNestedException("Cannot borrow connection from pool", e);
               } catch (RuntimeException e) {
                   closeDueToException(info);
                   throw e;
  @@ -980,7 +980,7 @@
                   throw e;
               } catch (Exception e) {
                   closeDueToException(info);
  -                throw new SQLException(e.getMessage());
  +                throw new SQLNestedException("Cannot borrow connection from pool", e);
               }
           } else {
               // assume KeyedObjectPool
  @@ -990,7 +990,7 @@
                       ((KeyedObjectPool) pool).borrowObject(upkey);
               } catch (NoSuchElementException e) {
                   closeDueToException(info);
  -                throw new SQLException(e.getMessage());
  +                throw new SQLNestedException("Cannot borrow connection from pool", e);
               } catch (RuntimeException e) {
                   closeDueToException(info);
                   throw e;
  @@ -999,7 +999,7 @@
                   throw e;
               } catch (Exception e) {
                   closeDueToException(info);
  -                throw new SQLException(e.getMessage());
  +                throw new SQLNestedException("Cannot borrow connection from pool", e);
               }
           }
           if (!(null == password ? null == info.getPassword() 
  
  
  
  1.8       +8 -9      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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- KeyedCPDSConnectionFactory.java	29 Jun 2003 12:42:16 -0000	1.7
  +++ KeyedCPDSConnectionFactory.java	11 Aug 2003 16:02:10 -0000	1.8
  @@ -74,6 +74,7 @@
   import javax.sql.ConnectionPoolDataSource;
   import javax.sql.PooledConnection;
   
  +import org.apache.commons.dbcp.SQLNestedException;
   import org.apache.commons.pool.KeyedObjectPool;
   import org.apache.commons.pool.KeyedPoolableObjectFactory;
   
  @@ -139,12 +140,10 @@
           if (null != _pool && pool != _pool) {
               try {
                   _pool.close();
  +            } catch (RuntimeException e) {
  +                throw e;
               } catch (Exception e) {
  -                if (e instanceof RuntimeException) {
  -                    throw (RuntimeException)e;
  -                } else {
  -                    throw new SQLException(e.getMessage());
  -                }
  +                throw new SQLNestedException("Cannot set the pool on this factory", e);
               }
           }
           _pool = pool;
  
  
  

Mime
View raw message