avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource AbstractJdbcConnection.java JdbcConnection.java Jdbc3Connection.java JdbcConnectionFactory.java Jdbc2Connection.java
Date Mon, 05 Nov 2001 13:45:27 GMT
bloritsch    01/11/05 05:45:27

  Modified:    .        build.xml
               src/java/org/apache/avalon/excalibur/datasource
                        Jdbc3Connection.java JdbcConnectionFactory.java
  Added:       src/java/org/apache/avalon/excalibur/datasource
                        AbstractJdbcConnection.java JdbcConnection.java
  Removed:     src/java/org/apache/avalon/excalibur/datasource
                        Jdbc2Connection.java
  Log:
  Change to DataSource heirarchy.  Including conditional compile
  
  Revision  Changes    Path
  1.74      +53 -11    jakarta-avalon-excalibur/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/build.xml,v
  retrieving revision 1.73
  retrieving revision 1.74
  diff -u -r1.73 -r1.74
  --- build.xml	2001/10/31 19:32:17	1.73
  +++ build.xml	2001/11/05 13:45:27	1.74
  @@ -46,7 +46,6 @@
     <!-- Set the properties for intermediate directory -->
     <property name="build.dir" value="build"/>
     <property name="build.lib" value="${build.dir}/lib"/>
  -  <property name="build.src" value="${build.dir}/src"/>
     <property name="build.classes" value="${build.dir}/classes"/>
     <property name="build.scratchpad" value="${build.dir}/scratchpad"/>
     <property name="build.javadocs" value="${build.dir}/javadocs"/>
  @@ -185,18 +184,20 @@
       <property name="j2ee.present" value="true"/>
     </target>
   
  -  <target name="jdbc2" unless="jdbc3.present">
  -    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/Jdbc2Connection.java"
  -          tofile="${build.src}/org/apache/avalon/excalibur/datasource/JdbcConnection.java"/>
  +  <target name="prepare-jdbc" depends="filter-jdbc,nofilter-jdbc"/>
  +
  +  <target name="filter-jdbc" unless="jdbc3.present">
  +    <filter token="JDBC3_START" value="/*"/>
  +    <filter token="JDBC3_END" value="*/"/>
     </target>
   
  -  <target name="jdbc3" if="jdbc3.present">
  -    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/Jdbc3Connection.java"
  -          tofile="${build.src}/org/apache/avalon/excalibur/datasource/JdbcConnection.java"
/>
  +  <target name="nofilter-jdbc" if="jdbc3.present">
  +    <filter token="JDBC3_START" value=""/>
  +    <filter token="JDBC3_END" value=""/>
     </target>
   
     <!-- Prepares the build directory -->
  -  <target name="prepare" depends="check-datasource,setup-properties,jdbc2,jdbc3">
  +  <target name="prepare" depends="check-datasource,setup-properties,prepare-jdbc">
       <tstamp/>
       <mkdir dir="${build.dir}"/>
     </target>
  @@ -207,6 +208,28 @@
       <mkdir dir="${build.classes}"/>
       <mkdir dir="${build.scratchpad}"/>
   
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.tmp"
  +          filtering="no"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.tmp"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java"
  +          filtering="yes"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.java"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.tmp"
  +          filtering="no"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.tmp"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.java"
  +          filtering="yes"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +
       <copy todir="${build.scratchpad}">
         <fileset dir="${scratchpad.dir}">
           <include name="**/test/**"/>
  @@ -235,16 +258,18 @@
              deprecation="${build.deprecation}">
         <classpath refid="project.class.path" />
         <src path="${test.dir}"/>
  -      <src path="${build.src}"/>
         <exclude name="org/apache/avalon/excalibur/datasource/J2eeDataSource.java"
                  unless="j2ee.present"/>
         <exclude name="org/apache/avalon/excalibur/datasource/InformixDataSource.java"
                  unless="informix.present"/>
         <exclude name="org/apache/avalon/excalibur/datasource/Jdbc2Connection.java"/>
  -      <exclude name="**/Jaxen*"              unless="jaxen.present"/>
  +      <exclude name="**/Jaxen*"
  +               unless="jaxen.present"/>
         <exclude name="org/apache/avalon/excalibur/xml/xpath/XPathProcessorImpl.java"
                  unless="xpath.present"/>
  -      <exclude name="org/apache/avalon/excalibur/datasource/Jdbc3Connection.java"/>
  +      <exclude name="org/apache/avalon/excalibur/datasource/Jdbc3Connection.java"
  +               unless="jdbc3.present"/>
  +      <exclude name="java/sql/Savepoint.java" if="jdbc3.present"/>
         <exclude name="org/apache/avalon/excalibur/logger/factory/ServletTargetFactory.java"
                  unless="servlet.present"/>
         <exclude name="org/apache/avalon/excalibur/logger/factory/JMSTargetFactory.java"
  @@ -269,6 +294,23 @@
         <classpath refid="project.class.path" />
       </rmic>
   
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.tmp"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java"
  +          filtering="no"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +
  +    <copy file="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.tmp"
  +          tofile="${java.dir}/org/apache/avalon/excalibur/datasource/JdbcConnection.java"
  +          filtering="no"
  +          overwrite="yes"
  +          preservelastmodified="yes"/>
  +
  +    <delete>
  +      <fileset dir="${java.dir}/org/apache/avalon/excalibur/datasource">
  +        <include name="*.tmp"/>
  +      </fileset>
  +    </delete>
     </target>
   
     <target name="test" depends="check"/>
  
  
  
  1.8       +29 -249   jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/Jdbc3Connection.java
  
  Index: Jdbc3Connection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/Jdbc3Connection.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Jdbc3Connection.java	2001/11/01 14:25:57	1.7
  +++ Jdbc3Connection.java	2001/11/05 13:45:27	1.8
  @@ -16,11 +16,6 @@
   import java.sql.Statement;
   import java.sql.Savepoint;
   import java.util.Map;
  -import org.apache.avalon.framework.logger.AbstractLogEnabled;
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.excalibur.pool.Recyclable;
  -import org.apache.avalon.excalibur.pool.Pool;
  -import org.apache.avalon.framework.logger.Logger;
   
   /**
    * The Connection object used in conjunction with the JdbcDataSource
  @@ -31,94 +26,17 @@
    * total number of Connection objects that are created.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/11/01 14:25:57 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/11/05 13:45:27 $
    * @since 4.0
    */
  -public class JdbcConnection
  -    extends AbstractLogEnabled
  -    implements Connection, Recyclable, Disposable
  +public class Jdbc3Connection
  +    extends AbstractJdbcConnection
   {
  -    protected Connection         m_connection;
  -    protected Pool               m_pool;
  -    protected PreparedStatement  m_test_statement;
  -    protected SQLException       m_test_exception;
  -    protected int                m_num_uses        = 15;
  -    protected final boolean      m_isJDBC3;
  -
  -    /**
  -     * @deprecated Use the version with keepAlive specified
  -     */
  -    public JdbcConnection( final Connection connection, final boolean oradb )
  -    {
  -        this(connection, (oradb) ? "select 1 from dual" : "select 1");
  -    }
  -
  -    public JdbcConnection( final Connection connection, final String keepAlive )
  -    {
  -        m_connection = connection;
  -
  -        // subclasses can override initialize()
  -        this.initialize();
  -
  -        if (null != keepAlive && "".equals(keepAlive.trim()))
  -        {
  -            try
  -            {
  -                m_test_statement = prepareStatement(keepAlive);
  -            }
  -            catch ( final SQLException se )
  -            {
  -                m_test_statement = null;
  -                m_test_exception = se;
  -            }
  -        }
  -        else
  -        {
  -            m_test_statement = null;
  -            m_test_exception = null;
  -        }
  -
  -        boolean use3 = false;
  -        try
  -        {
  -            java.lang.reflect.Method meth = m_connection.getClass().getMethod("getHoldability",
new Class[] {});
  -            use3 = true;
  -        }
  -        catch (Exception e)
  -        {
  -            use3 = false;
  -        }
  -
  -        m_isJDBC3 = use3;
  -    }
  -
  -    /**
  -     * Extend this for connection initialization--only needed for some drivers.
  -     */
  -    public void initialize()
  -    {
  -    }
  -
  -    protected void setPool(Pool pool)
  +    public Jdbc3Connection( final Connection connection, final String keepAlive )
       {
  -        this.m_pool = pool;
  +        super( connection, keepAlive );
       }
   
  -    public final void enableLogging( final Logger log )
  -    {
  -        super.enableLogging(log);
  -
  -        if (m_test_statement == null)
  -        {
  -            if (getLogger().isWarnEnabled())
  -            {
  -                getLogger().warn("Could not prepare test statement", m_test_exception);
  -            }
  -
  -            m_test_exception = null;
  -        }
  -    }
  -
       public final Statement createStatement()
           throws SQLException
       {
  @@ -167,60 +85,6 @@
           m_connection.rollback();
       }
   
  -    public final void close()
  -        throws SQLException
  -    {
  -        clearWarnings();
  -        m_pool.put( this );
  -    }
  -
  -    public final void dispose()
  -    {
  -        try { m_connection.close(); }
  -        catch( final SQLException se )
  -        {
  -            if (getLogger().isWarnEnabled())
  -            {
  -                getLogger().warn( "Could not close connection", se );
  -            }
  -        }
  -    }
  -
  -    public final void recycle() {
  -        this.m_num_uses--;
  -        this.m_test_exception = null;
  -    }
  -
  -    public final boolean isClosed()
  -        throws SQLException
  -    {
  -        if ( m_connection.isClosed())
  -        {
  -            return true;
  -        }
  -
  -        if ( this.m_num_uses <= 0 )
  -        {
  -            this.dispose();
  -            return true;
  -        }
  -
  -        if (m_test_statement != null)
  -        {
  -            try
  -            {
  -                m_test_statement.executeQuery();
  -            }
  -            catch (final SQLException se)
  -            {
  -                this.dispose();
  -                return true;
  -            }
  -        }
  -
  -        return false;
  -    }
  -
       public final DatabaseMetaData getMetaData()
           throws SQLException
       {
  @@ -307,85 +171,43 @@
       public final void setTypeMap( final Map map )
           throws SQLException
       {
  -        m_connection.setTypeMap( map );
  +         m_connection.setTypeMap( map );
       }
   
       public final void setHoldability(int holdability)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           m_connection.setHoldability(holdability);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        m_connection.setHoldability(holdability);
       }
   
       public final int getHoldability()
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.getHoldability();
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.getHoldability();
       }
   
       public final Savepoint setSavepoint()
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.setSavepoint();
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.setSavepoint();
       }
   
       public final Savepoint setSavepoint(String savepoint)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.setSavepoint(savepoint);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.setSavepoint(savepoint);
       }
   
       public final void rollback(Savepoint savepoint)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           m_connection.rollback(savepoint);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        m_connection.rollback(savepoint);
       }
   
       public final void releaseSavepoint(Savepoint savepoint)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           m_connection.releaseSavepoint(savepoint);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        m_connection.releaseSavepoint(savepoint);
       }
   
       public final Statement createStatement(int resulSetType,
  @@ -393,16 +215,9 @@
                                              int resultSetHoldability)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.createStatement(resulSetType,
  -                                               resultSetConcurrency,
  -                                               resultSetHoldability);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.createStatement(resulSetType,
  +                                            resultSetConcurrency,
  +                                            resultSetHoldability);
       }
   
       public final PreparedStatement prepareStatement(String sql,
  @@ -411,17 +226,10 @@
                                           int resultSetHoldability)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.prepareStatement(sql,
  -                                                resulSetType,
  -                                                resultSetConcurrency,
  -                                                resultSetHoldability);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.prepareStatement(sql,
  +                                             resulSetType,
  +                                             resultSetConcurrency,
  +                                             resultSetHoldability);
       }
   
       public final CallableStatement prepareCall(String sql,
  @@ -430,61 +238,33 @@
                                           int resultSetHoldability)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.prepareCall(sql,
  -                                           resulSetType,
  -                                           resultSetConcurrency,
  -                                           resultSetHoldability);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.prepareCall(sql,
  +                                        resulSetType,
  +                                        resultSetConcurrency,
  +                                        resultSetHoldability);
       }
   
       public final PreparedStatement prepareStatement(String sql,
                                           int autoGeneratedKeys)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.prepareStatement(sql,
  -                                                autoGeneratedKeys);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.prepareStatement(sql,
  +                                             autoGeneratedKeys);
       }
   
       public final PreparedStatement prepareStatement(String sql,
                                           int[] columnIndexes)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.prepareStatement(sql,
  -                                                columnIndexes);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +        return m_connection.prepareStatement(sql,
  +                                             columnIndexes);
       }
   
       public final PreparedStatement prepareStatement(String sql,
                                           String[] columnNames)
           throws SQLException
       {
  -       if (m_isJDBC3)
  -       {
  -           return m_connection.prepareStatement(sql,
  -                                                columnNames);
  -       }
  -       else
  -       {
  -           throw new SQLException("Not a JDBC 3.0 compliant Connection");
  -       }
  +       return m_connection.prepareStatement(sql,
  +                                            columnNames);
       }
   }
  
  
  
  1.7       +20 -5     jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionFactory.java
  
  Index: JdbcConnectionFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/JdbcConnectionFactory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JdbcConnectionFactory.java	2001/11/01 14:25:57	1.6
  +++ JdbcConnectionFactory.java	2001/11/05 13:45:27	1.7
  @@ -18,7 +18,7 @@
    * The Factory implementation for JdbcConnections.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/11/01 14:25:57 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/11/05 13:45:27 $
    * @since 4.0
    */
   public class JdbcConnectionFactory extends AbstractLogEnabled implements ObjectFactory
  @@ -28,7 +28,7 @@
       private final String m_password;
       private final boolean m_autoCommit;
       private final String m_keepAlive;
  -    private final String m_connectionClass;
  +    private       String m_connectionClass;
       private final static String DEFAULT_KEEPALIVE = "SELECT 1";
       private final static String ORACLE_KEEPALIVE = JdbcConnectionFactory.DEFAULT_KEEPALIVE
+ " FROM DUAL";
   
  @@ -90,15 +90,24 @@
   
           if ( null == this.m_connectionClass )
           {
  -            jdbcConnection = new JdbcConnection(connection, m_keepAlive);
  +            try
  +            {
  +                java.lang.reflect.Method meth = connection.getClass().getMethod("getHoldability",
new Class[] {});
  +                this.m_connectionClass = "org.apache.avalon.excalibur.datasource.Jdbc3Connection";
  +            }
  +            catch (Exception e)
  +            {
  +                this.m_connectionClass = "org.apache.avalon.excalibur.datasource.JdbcConnection";
  +            }
           }
  -        else
  +
  +        if ( null != this.m_connectionClass )
           {
               try
               {
                   Class clazz = Thread.currentThread().getContextClassLoader().loadClass(
this.m_connectionClass );
                   Class[] paramTypes = new Class[] { Connection.class, String.class };
  -                Object[] params = new Object[] { connection, new Boolean( this.m_keepAlive
) };
  +                Object[] params = new Object[] { connection, this.m_keepAlive };
   
                   Constructor constructor = clazz.getConstructor( paramTypes );
                   jdbcConnection = (JdbcConnection) constructor.newInstance( params );
  @@ -120,8 +129,14 @@
                       {
                           getLogger().debug("Exception in JdbcConnectionFactory.newInstance:",
ie);
                       }
  +
  +                    throw new NoValidConnectionException(ie.getMessage());
                   }
               }
  +        }
  +        else
  +        {
  +            throw new NoValidConnectionException("No valid JdbcConnection class available");
           }
   
           jdbcConnection.enableLogging(getLogger());
  
  
  
  1.1                  jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/AbstractJdbcConnection.java
  
  Index: AbstractJdbcConnection.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.excalibur.datasource;
  
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import java.sql.CallableStatement;
  import java.sql.Connection;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.Statement;
  import org.apache.avalon.framework.logger.AbstractLogEnabled;
  import org.apache.avalon.framework.activity.Initializable;
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.excalibur.pool.Recyclable;
  import org.apache.avalon.excalibur.pool.Pool;
  import org.apache.avalon.framework.logger.Logger;
  
  /**
   * The Connection object used in conjunction with the JdbcDataSource
   * object.
   *
   * TODO: Implement a configurable closed end Pool, where the Connection
   * acts like JDBC PooledConnections work.  That means we can limit the
   * total number of Connection objects that are created.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/11/05 13:45:27 $
   * @since 4.1
   */
  public abstract class AbstractJdbcConnection
      extends AbstractLogEnabled
      implements Connection, Recyclable, Disposable, Initializable
  {
      protected Connection         m_connection;
      protected Pool               m_pool;
      protected PreparedStatement  m_test_statement;
      protected SQLException       m_test_exception;
      protected int                m_num_uses        = 15;
  
      /**
       * Private default constructor so that it cannot be instantiated any
       * other way than we desire.
       */
      private AbstractJdbcConnection() {}
  
      /**
       * @deprecated Use the version with keepAlive specified
       */
      public AbstractJdbcConnection( final Connection connection, final boolean oradb )
      {
          this(connection, (oradb) ? "select 1 from dual" : "select 1");
      }
  
      public AbstractJdbcConnection( final Connection connection, final String keepAlive )
      {
          m_connection = connection;
  
          // subclasses can override initialize()
          this.initialize();
  
          if (null != keepAlive && "".equals(keepAlive.trim()))
          {
              try
              {
                  m_test_statement = prepareStatement(keepAlive);
              }
              catch ( final SQLException se )
              {
                  m_test_statement = null;
                  m_test_exception = se;
              }
          }
          else
          {
              m_test_statement = null;
              m_test_exception = null;
          }
      }
  
      public void initialize() {}
  
      public void enableLogging( final Logger log )
      {
          super.enableLogging(log);
  
          if (m_test_statement == null && m_test_exception != null)
          {
              if (getLogger().isWarnEnabled())
              {
                  getLogger().warn("Could not prepare test statement", m_test_exception);
              }
              m_test_exception = null;
          }
      }
  
      protected void setPool(Pool pool)
      {
          this.m_pool = pool;
      }
  
      public void recycle() {
          this.m_num_uses--;
          this.m_test_exception = null;
      }
  
      public boolean isClosed()
          throws SQLException
      {
          if ( m_connection.isClosed())
          {
              return true;
          }
  
          if ( this.m_num_uses <= 0 )
          {
              this.dispose();
              return true;
          }
  
          if (m_test_statement != null)
          {
              try
              {
                  m_test_statement.executeQuery();
              }
              catch (final SQLException se)
              {
                  this.dispose();
                  return true;
              }
          }
  
          return false;
      }
  
      public void close()
          throws SQLException
      {
          clearWarnings();
          m_pool.put( this );
      }
  
      public void dispose()
      {
          try { m_connection.close(); }
          catch( final SQLException se )
          {
              if (getLogger().isWarnEnabled())
              {
                  getLogger().warn( "Could not close connection", se );
              }
          }
      }
  
  /*
      public abstract void setHoldability(int holdability)
          throws SQLException;
  
      public abstract int getHoldability()
          throws SQLException;
  
      public abstract java.sql.Savepoint setSavepoint()
          throws SQLException;
  
      public abstract java.sql.Savepoint setSavepoint(String savepoint)
          throws SQLException;
  
      public abstract void rollback(java.sql.Savepoint savepoint)
          throws SQLException;
  
      public abstract void releaseSavepoint(java.sql.Savepoint savepoint)
          throws SQLException;
  
      public abstract Statement createStatement(int resulSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
          throws SQLException;
  
      public abstract PreparedStatement prepareStatement(String sql,
                                          int resulSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
          throws SQLException;
  
      public abstract CallableStatement prepareCall(String sql,
                                          int resulSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
          throws SQLException;
  
      public abstract PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
          throws SQLException;
  
      public abstract PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
          throws SQLException;
  
      public abstract PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
          throws SQLException;
  */
  }
  
  
  
  1.1                  jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/datasource/JdbcConnection.java
  
  Index: JdbcConnection.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.excalibur.datasource;
  
  import java.sql.CallableStatement;
  import java.sql.Connection;
  import java.sql.DatabaseMetaData;
  import java.sql.PreparedStatement;
  import java.sql.SQLException;
  import java.sql.SQLWarning;
  import java.sql.Statement;
  import java.util.Map;
  
  /**
   * The Connection object used in conjunction with the JdbcDataSource
   * object.
   *
   * TODO: Implement a configurable closed end Pool, where the Connection
   * acts like JDBC PooledConnections work.  That means we can limit the
   * total number of Connection objects that are created.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/11/05 13:45:27 $
   * @since 4.0
   */
  public class JdbcConnection
      extends AbstractJdbcConnection
  {
  
      public JdbcConnection( final Connection connection, final String keepAlive )
      {
          super( connection, keepAlive );
      }
  
      public final Statement createStatement()
          throws SQLException
      {
          return m_connection.createStatement();
      }
  
      public final PreparedStatement prepareStatement( final String sql )
          throws SQLException
      {
          return m_connection.prepareStatement( sql );
      }
  
      public final CallableStatement prepareCall( final String sql )
          throws SQLException
      {
          return m_connection.prepareCall( sql );
      }
  
      public final String nativeSQL( final String sql )
          throws SQLException
      {
          return m_connection.nativeSQL( sql );
      }
  
      public final void setAutoCommit( final boolean autoCommit )
          throws SQLException
      {
          m_connection.setAutoCommit( autoCommit );
      }
  
      public final boolean getAutoCommit()
          throws SQLException
      {
          return m_connection.getAutoCommit();
      }
  
      public final void commit()
          throws SQLException
      {
          m_connection.commit();
      }
  
      public final void rollback()
          throws SQLException
      {
          m_connection.rollback();
      }
  
      public final DatabaseMetaData getMetaData()
          throws SQLException
      {
          return m_connection.getMetaData();
      }
  
      public final void setReadOnly( final boolean readOnly )
          throws SQLException
      {
          m_connection.setReadOnly( readOnly );
      }
  
      public final boolean isReadOnly()
          throws SQLException
      {
          return m_connection.isReadOnly();
      }
  
      public final void setCatalog( final String catalog )
          throws SQLException
      {
          m_connection.setCatalog( catalog );
      }
  
      public final String getCatalog()
          throws SQLException
      {
          return m_connection.getCatalog();
      }
  
      public final void setTransactionIsolation( final int level )
          throws SQLException
      {
          m_connection.setTransactionIsolation(level);
      }
  
      public final int getTransactionIsolation()
          throws SQLException
      {
          return m_connection.getTransactionIsolation();
      }
  
      public final SQLWarning getWarnings()
          throws SQLException
      {
          return m_connection.getWarnings();
      }
  
      public final void clearWarnings()
          throws SQLException
      {
          m_connection.clearWarnings();
      }
  
      public final Statement createStatement( final int resultSetType,
                                              final int resultSetConcurrency )
          throws SQLException
      {
          return m_connection.createStatement(resultSetType, resultSetConcurrency);
      }
  
      public final PreparedStatement prepareStatement( final String sql,
                                                 final int resultSetType,
                                                 final int resultSetConcurrency )
          throws SQLException
      {
          return m_connection.prepareStatement( sql, resultSetType, resultSetConcurrency );
      }
  
      public final CallableStatement prepareCall( final String sql,
                                            final int resultSetType,
                                            final int resultSetConcurrency )
          throws SQLException
      {
          return m_connection.prepareCall( sql, resultSetType, resultSetConcurrency );
      }
  
      public final Map getTypeMap()
          throws SQLException
      {
          return m_connection.getTypeMap();
      }
  
      public final void setTypeMap( final Map map )
          throws SQLException
      {
          m_connection.setTypeMap( map );
      }
  
  /*
      public final void setHoldability(int holdability)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final int getHoldability()
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final java.sql.Savepoint setSavepoint()
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final java.sql.Savepoint setSavepoint(String savepoint)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final void rollback(java.sql.Savepoint savepoint)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final void releaseSavepoint(java.sql.Savepoint savepoint)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final Statement createStatement(int resulSetType,
                                             int resultSetConcurrency,
                                             int resultSetHoldability)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final PreparedStatement prepareStatement(String sql,
                                          int resulSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final CallableStatement prepareCall(String sql,
                                          int resulSetType,
                                          int resultSetConcurrency,
                                          int resultSetHoldability)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final PreparedStatement prepareStatement(String sql,
                                          int autoGeneratedKeys)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final PreparedStatement prepareStatement(String sql,
                                          int[] columnIndexes)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  
      public final PreparedStatement prepareStatement(String sql,
                                          String[] columnNames)
          throws SQLException
      {
          throw new SQLException("This is not a Jdbc 3.0 Compliant Connection");
      }
  */
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message