Class CachingLogicalConnection

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

    public class CachingLogicalConnection
    extends LogicalConnection
    A logical connection used in a connection pool with capabilities for caching prepared statements.

    An instance of this class is what is passed out the the client. It uses a JDBC statement object cache to avoid re-preparing commonly used queries. The cache has scope of a physical connection, and is lost when the pooled connection is closed (which includes closing the physical connection).

    See Also:
    StatementCacheInteractor
    • Field Detail

      • cacheInteractor

        private StatementCacheInteractor cacheInteractor
        JDBC statement cache interactor used to prepare statements and calls.
    • Constructor Detail

      • CachingLogicalConnection

        public CachingLogicalConnection​(ClientConnection physicalConnection,
                                        ClientPooledConnection pooledConnection,
                                        JDBCStatementCache stmtCache)
                                 throws SqlException
        Creates a new logical connection which caches prepared statements.
        Parameters:
        physicalConnection - underlying physical database connection
        pooledConnection - associated pooled connection
        stmtCache - associated statement cache
        Throws:
        SqlException - if creating the logical connection fails
    • Method Detail

      • close

        public void close()
                   throws java.sql.SQLException
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.sql.Connection
        Overrides:
        close in class LogicalConnection
        Throws:
        java.sql.SQLException
      • prepareStatement

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

        public java.sql.PreparedStatement prepareStatement​(java.lang.String sql,
                                                           int resultSetType,
                                                           int resultSetConcurrency)
                                                    throws java.sql.SQLException
        Specified by:
        prepareStatement in interface java.sql.Connection
        Overrides:
        prepareStatement in class LogicalConnection
        Throws:
        java.sql.SQLException
      • 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 LogicalConnection
        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 LogicalConnection
        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 LogicalConnection
        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 LogicalConnection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class LogicalConnection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class LogicalConnection
        Throws:
        java.sql.SQLException
      • prepareCall

        public java.sql.CallableStatement prepareCall​(java.lang.String sql,
                                                      int resultSetType,
                                                      int resultSetConcurrency,
                                                      int resultSetHoldability)
                                               throws java.sql.SQLException
        Specified by:
        prepareCall in interface java.sql.Connection
        Overrides:
        prepareCall in class LogicalConnection
        Throws:
        java.sql.SQLException