User: mulder  
  Date: 00/08/31 10:28:46

  Modified:    src/main/org/jboss/minerva/factories
                        JDBCConnectionFactory.java XAConnectionFactory.java
  Log:
  Non-transactional pools and JDBC 1/2 wrapper transactional pools will now
  boot a connection out of the pool if there's an error during commit or
  rollback.  Note that with a native JDBC 2 Standard Extension driver, we
  have no way of knowing what method caused an exception so the only way to
  achieve this is to set the invalidateOnError property, which boots the
  connection for *all* exceptions.
  
  Revision  Changes    Path
  1.5       +15 -2     
jboss/src/main/org/jboss/minerva/factories/JDBCConnectionFactory.java
  
  Index: JDBCConnectionFactory.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/factories/JDBCConnectionFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- JDBCConnectionFactory.java        2000/08/31 16:37:08     1.4
  +++ JDBCConnectionFactory.java        2000/08/31 17:28:46     1.5
  @@ -21,7 +21,7 @@
    * you're interested in creating transactional-aware connections, see
    * XAConnectionFactory, which complies with the JDBC 2.0 standard extension.
    * @see org.jboss.minerva.factories.XAConnectionFactory
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class JDBCConnectionFactory extends PoolObjectFactory {
  @@ -30,6 +30,7 @@
       private String userName;
       private String password;
       private PrintWriter log;
  +    private ObjectPool pool;
   
       /**
        * Creates a new factory.  You must configure it with JDBC properties
  @@ -88,9 +89,19 @@
           super.poolStarted(pool, log);
           if(url == null)
               throw new IllegalStateException("Must specify JDBC connection URL to 
"+getClass().getName());
  +        this.pool = pool;
       }
   
       /**
  +     * Cleans up.
  +     */
  +    public void poolClosing(ObjectPool pool) {
  +        super.poolClosing(pool);
  +        this.pool = null;
  +        log = null;
  +    }
  +
  +    /**
        * Creates a new JDBC Connection.
        */
       public Object createObject() {
  @@ -134,7 +145,9 @@
           Connection con = wrapper.getUnderlyingConnection();
           try {
               wrapper.reset();
  -        } catch(SQLException e) {}
  +        } catch(SQLException e) {
  +            pool.markObjectAsInvalid(clientObject);
  +        }
           return con;
       }
   
  
  
  
  1.7       +15 -2     
jboss/src/main/org/jboss/minerva/factories/XAConnectionFactory.java
  
  Index: XAConnectionFactory.java
  ===================================================================
  RCS file: 
/products/cvs/ejboss/jboss/src/main/org/jboss/minerva/factories/XAConnectionFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XAConnectionFactory.java  2000/08/30 12:41:51     1.6
  +++ XAConnectionFactory.java  2000/08/31 17:28:46     1.7
  @@ -38,7 +38,7 @@
    * connection, the same previous connection will be returned.  Otherwise,
    * you won't be able to share changes across connections like you can with
    * the native JDBC 2 Standard Extension implementations.</P>
  - * @version $Revision: 1.6 $
  + * @version $Revision: 1.7 $
    * @author Aaron Mulder ([EMAIL PROTECTED])
    */
   public class XAConnectionFactory extends PoolObjectFactory {
  @@ -90,7 +90,11 @@
                   } else {
                       if(trans == null) {
                           // Wrapper - we can only release it if there's no current 
transaction
  -                        ((XAConnectionImpl)con).rollback();
  +                        try {
  +                            ((XAConnectionImpl)con).rollback();
  +                        } catch(SQLException e) {
  +                            pool.markObjectAsInvalid(con);
  +                        }
                           pool.releaseObject(con);
                       }
                   }
  @@ -102,6 +106,15 @@
                   Object tx = wrapperTx.remove(con);
                   if(tx != null)
                       wrapperTx.remove(tx);
  +                pool.releaseObject(con);
  +            }
  +
  +            public void transactionFailed(XAConnectionImpl con) {
  +                con.clearTransactionListener();
  +                Object tx = wrapperTx.remove(con);
  +                if(tx != null)
  +                    wrapperTx.remove(tx);
  +                pool.markObjectAsInvalid(con);
                   pool.releaseObject(con);
               }
           };
  
  
  

Reply via email to