Class ConnectionImpl

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.sql.Connection, java.sql.Wrapper

    class ConnectionImpl
    extends DelegatingConnection
    This class is the Connection that will be returned from PooledConnectionImpl.getConnection(). Most methods are wrappers around the jdbc 1.x Connection. A few exceptions include preparedStatement and close. In accordance with the jdbc specification this Connection cannot be used after closed() is called. Any further usage will result in an SQLException. ConnectionImpl extends DelegatingConnection to enable access to the underlying connection.
    Version:
    $Revision: 896266 $ $Date: 2010-01-05 18:20:12 -0500 (Tue, 05 Jan 2010) $
    • Field Detail

      • accessToUnderlyingConnectionAllowed

        private final boolean accessToUnderlyingConnectionAllowed
      • pooledConnection

        private final PooledConnectionImpl pooledConnection
        The object that instantiated this object
    • Constructor Detail

      • ConnectionImpl

        ConnectionImpl​(PooledConnectionImpl pooledConnection,
                       java.sql.Connection connection,
                       boolean accessToUnderlyingConnectionAllowed)
        Creates a ConnectionImpl.
        Parameters:
        pooledConnection - The PooledConnection that is calling the ctor.
        connection - The JDBC 1.x Connection to wrap.
        accessToUnderlyingConnectionAllowed - if true, then access is allowed to the underlying connectiion
    • Method Detail

      • close

        public void close()
                   throws java.sql.SQLException
        Marks the Connection as closed, and notifies the pool that the pooled connection is available. In accordance with the jdbc specification this Connection cannot be used after closed() is called. Any further usage will result in an SQLException.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Overrides:
        close in class DelegatingConnection
        Throws:
        java.sql.SQLException - The database connection couldn't be closed.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql)
                                                    throws java.sql.SQLException
        If pooling of PreparedStatements is turned on in the DriverAdapterCPDS, a pooled object may be returned, otherwise delegate to the wrapped jdbc 1.x Connection.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Parameters:
        sql - SQL statement to be prepared
        Returns:
        the prepared statement
        Throws:
        java.sql.SQLException - if this connection is closed or an error occurs in the wrapped connection.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency)
                                                    throws java.sql.SQLException
        If pooling of PreparedStatements is turned on in the DriverAdapterCPDS, a pooled object may be returned, otherwise delegate to the wrapped jdbc 1.x Connection.
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Throws:
        java.sql.SQLException - if this connection is closed or an error occurs in the wrapped connection.
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency,
                                                           int resultSetHoldability)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int autoGeneratedKeys)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int[] columnIndexes)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Throws:
        java.sql.SQLException
      • prepareStatement

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           java.lang.String[] columnNames)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class DelegatingConnection
        Throws:
        java.sql.SQLException
      • isAccessToUnderlyingConnectionAllowed

        public boolean isAccessToUnderlyingConnectionAllowed()
        If false, getDelegate() and getInnermostDelegate() will return null.
        Returns:
        true if access is allowed to the underlying connection
        See Also:
        ConnectionImpl