Class ConnectionHolder

    • Field Detail

      • wrappedAlready

        protected boolean wrappedAlready
      • isClosed

        protected boolean isClosed
      • valid

        protected boolean valid
      • active

        protected boolean active
      • statementTimeout

        protected int statementTimeout
      • statementTimeoutEnabled

        protected boolean statementTimeoutEnabled
      • sm

        protected static final StringManager sm
        The active flag is false when the connection handle is created. When a method is invoked on this object, it asks the ManagedConnection if it can be the active connection handle out of the multiple connection handles. If the ManagedConnection reports that this connection handle can be active by setting this flag to true via the setActive function, the above method invocation succeeds; otherwise an exception is thrown.
    • Constructor Detail

      • ConnectionHolder

        public ConnectionHolder​(Connection con,
                                ManagedConnectionImpl mc,
                                jakarta.resource.spi.ConnectionRequestInfo cxRequestInfo)
        Constructs a Connection holder.
        Parameters:
        con - java.sql.Connection object.
    • Method Detail

      • getConnection

        public Connection getConnection()
                                 throws SQLException
        Returns the actual connection in this holder object.
        Returns:
        Connection object.
        Throws:
        SQLException
      • wrapped

        public void wrapped​(boolean wrapFlag)
        Sets the flag to indicate that, the connection is wrapped already or not.
        Parameters:
        wrapFlag -
      • isWrapped

        public boolean isWrapped()
        Returns whether it is wrapped already or not.
        Returns:
        wrapped flag.
      • getManagedConnection

        public ManagedConnectionImpl getManagedConnection()
        Returns the ManagedConnection instance responsible for this connection.
        Returns:
        ManagedConnection instance.
      • associateConnection

        public void associateConnection​(Connection con,
                                        ManagedConnectionImpl mc)
        Replace the actual java.sql.Connection object with the one supplied. Also replace ManagedConnection link.
        Parameters:
        con - Connection object.
        mc - ManagedConnection object.
      • dissociateConnection

        public void dissociateConnection()
        Dis-associate ManagedConnection and actual-connection from this user connection. Used when lazy-connection-association is ON.
      • clearWarnings

        public void clearWarnings()
                           throws SQLException
        Clears all warnings reported for the underlying connection object.
        Specified by:
        clearWarnings in interface Connection
        Throws:
        SQLException - In case of a database error.
      • invalidate

        public void invalidate()
        Invalidates this object.
      • createStatement

        public Statement createStatement​(int resultSetType,
                                         int resultSetConcurrency)
                                  throws SQLException
        Creates a statement from the underlying Connection.
        Specified by:
        createStatement in interface Connection
        Parameters:
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        Returns:
        Statement object.
        Throws:
        SQLException - In case of a database error.
      • createStatement

        public Statement createStatement​(int resultSetType,
                                         int resultSetConcurrency,
                                         int resultSetHoldability)
                                  throws SQLException
        Creates a statement from the underlying Connection.
        Specified by:
        createStatement in interface Connection
        Parameters:
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        resultSetHoldability - ResultSet Holdability.
        Returns:
        Statement object.
        Throws:
        SQLException - In case of a database error.
      • getAutoCommit

        public boolean getAutoCommit()
                              throws SQLException
        Retrieves the current auto-commit mode for the underlying Connection.
        Specified by:
        getAutoCommit in interface Connection
        Returns:
        The current state of connection's auto-commit mode.
        Throws:
        SQLException - In case of a database error.
      • getHoldability

        public int getHoldability()
                           throws SQLException
        Retrieves the current holdability of ResultSet objects created using this connection object.
        Specified by:
        getHoldability in interface Connection
        Returns:
        holdability value.
        Throws:
        SQLException - In case of a database error.
      • getTransactionIsolation

        public int getTransactionIsolation()
                                    throws SQLException
        Retrieves this Connection object's current transaction isolation level.
        Specified by:
        getTransactionIsolation in interface Connection
        Returns:
        Transaction level
        Throws:
        SQLException - In case of a database error.
      • getWarnings

        public SQLWarning getWarnings()
                               throws SQLException
        Retrieves the the first warning reported by calls on the underlying Connection object.
        Specified by:
        getWarnings in interface Connection
        Returns:
        First SQLWarning Object or null.
        Throws:
        SQLException - In case of a database error.
      • isClosed

        public boolean isClosed()
                         throws SQLException
        Retrieves whether underlying Connection object is closed.
        Specified by:
        isClosed in interface Connection
        Returns:
        true if Connection object is closed, false if it is closed.
        Throws:
        SQLException - In case of a database error.
      • setClosed

        public void setClosed​(boolean flag)
        Set the isClosed flag based on whether the underlying Connection object is closed.
        Parameters:
        flag - true if Connection object is closed, false if its not closed.
      • isReadOnly

        public boolean isReadOnly()
                           throws SQLException
        Retrieves whether this Connection object is read-only.
        Specified by:
        isReadOnly in interface Connection
        Returns:
        true if Connection is read-only, false other-wise
        Throws:
        SQLException - In case of a database error.
      • nativeSQL

        public String nativeSQL​(String sql)
                         throws SQLException
        Converts the given SQL statement into the system's native SQL grammer.
        Specified by:
        nativeSQL in interface Connection
        Parameters:
        sql - SQL statement , to be converted.
        Returns:
        Converted SQL string.
        Throws:
        SQLException - In case of a database error.
      • prepareCall

        public CallableStatement prepareCall​(String sql,
                                             int resultSetType,
                                             int resultSetConcurrency)
                                      throws SQLException
        Creates a CallableStatement object for calling database stored procedures.
        Specified by:
        prepareCall in interface Connection
        Parameters:
        sql - SQL Statement
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        Returns:
        CallableStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareCall

        public CallableStatement prepareCall​(String sql,
                                             int resultSetType,
                                             int resultSetConcurrency,
                                             int resultSetHoldability)
                                      throws SQLException
        Creates a CallableStatement object for calling database stored procedures.
        Specified by:
        prepareCall in interface Connection
        Parameters:
        sql - SQL Statement
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        resultSetHoldability - ResultSet Holdability.
        Returns:
        CallableStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int autoGeneratedKeys)
                                           throws SQLException
        Creates a PreparedStatement object for sending paramterized SQL statements to database
        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - SQL Statement
        autoGeneratedKeys - a flag indicating AutoGeneratedKeys need to be returned.
        Returns:
        PreparedStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int[] columnIndexes)
                                           throws SQLException
        Creates a PreparedStatement object for sending paramterized SQL statements to database
        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - SQL Statement
        columnIndexes - an array of column indexes indicating the columns that should be returned from the inserted row or rows.
        Returns:
        PreparedStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int resultSetType,
                                                  int resultSetConcurrency)
                                           throws SQLException
        Creates a PreparedStatement object for sending paramterized SQL statements to database
        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - SQL Statement
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        Returns:
        PreparedStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  int resultSetType,
                                                  int resultSetConcurrency,
                                                  int resultSetHoldability)
                                           throws SQLException
        Creates a PreparedStatement object for sending paramterized SQL statements to database
        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - SQL Statement
        resultSetType - Type of the ResultSet
        resultSetConcurrency - ResultSet Concurrency.
        resultSetHoldability - ResultSet Holdability.
        Returns:
        PreparedStatement object.
        Throws:
        SQLException - In case of a database error.
      • prepareStatement

        public PreparedStatement prepareStatement​(String sql,
                                                  String[] columnNames)
                                           throws SQLException
        Creates a PreparedStatement object for sending paramterized SQL statements to database
        Specified by:
        prepareStatement in interface Connection
        Parameters:
        sql - SQL Statement
        columnNames - Name of bound columns.
        Returns:
        PreparedStatement object.
        Throws:
        SQLException - In case of a database error.
      • releaseSavepoint

        public void releaseSavepoint​(Savepoint savepoint)
                              throws SQLException
        Removes the given Savepoint object from the current transaction.
        Specified by:
        releaseSavepoint in interface Connection
        Parameters:
        savepoint - Savepoint object
        Throws:
        SQLException - In case of a database error.
      • rollback

        public void rollback()
                      throws SQLException
        Rolls back the changes made in the current transaction.
        Specified by:
        rollback in interface Connection
        Throws:
        SQLException - In case of a database error.
      • setAutoCommit

        public void setAutoCommit​(boolean autoCommit)
                           throws SQLException
        Sets the auto-commmit mode of the Connection object.
        Specified by:
        setAutoCommit in interface Connection
        Parameters:
        autoCommit - boolean value indicating the auto-commit mode.
        Throws:
        SQLException - In case of a database error.
      • setCatalog

        public void setCatalog​(String catalog)
                        throws SQLException
        Sets the catalog name to the Connection object
        Specified by:
        setCatalog in interface Connection
        Parameters:
        catalog - Catalog name.
        Throws:
        SQLException - In case of a database error.
      • setHoldability

        public void setHoldability​(int holdability)
                            throws SQLException
        Sets the holdability of ResultSet objects created using this Connection object.
        Specified by:
        setHoldability in interface Connection
        Parameters:
        holdability - A ResultSet holdability constant
        Throws:
        SQLException - In case of a database error.
      • setReadOnly

        public void setReadOnly​(boolean readOnly)
                         throws SQLException
        Puts the connection in read-only mode as a hint to the driver to perform database optimizations.
        Specified by:
        setReadOnly in interface Connection
        Parameters:
        readOnly - true enables read-only mode, false disables it.
        Throws:
        SQLException - In case of a database error.
      • setSavepoint

        public Savepoint setSavepoint()
                               throws SQLException
        Creates and unnamed savepoint and returns an object corresponding to that.
        Specified by:
        setSavepoint in interface Connection
        Returns:
        Savepoint object.
        Throws:
        SQLException - In case of a database error.
      • setSavepoint

        public Savepoint setSavepoint​(String name)
                               throws SQLException
        Creates a savepoint with the name and returns an object corresponding to that.
        Specified by:
        setSavepoint in interface Connection
        Parameters:
        name - Name of the savepoint.
        Returns:
        Savepoint object.
        Throws:
        SQLException - In case of a database error.
      • setTransactionIsolation

        public void setTransactionIsolation​(int level)
                                     throws SQLException
        Creates the transaction isolation level.
        Specified by:
        setTransactionIsolation in interface Connection
        Parameters:
        level - transaction isolation level.
        Throws:
        SQLException - In case of a database error.
      • checkValidity

        protected void checkValidity()
                              throws SQLException
        Checks the validity of this object
        Throws:
        SQLException
      • setActive

        public void setActive​(boolean actv)
        Sets the active flag to true
        Parameters:
        actv - boolean
      • setLazyAssociatableConnectionManager

        public void setLazyAssociatableConnectionManager​(jakarta.resource.spi.LazyAssociatableConnectionManager cm)
      • setLazyEnlistableConnectionManager

        public void setLazyEnlistableConnectionManager​(jakarta.resource.spi.LazyEnlistableConnectionManager cm)
      • setTypeMap

        public void setTypeMap​(Map<String,​Class<?>> map)
                        throws SQLException
        Installs the given Map object as the tyoe map for this Connection object.
        Specified by:
        setTypeMap in interface Connection
        Parameters:
        map - Map a Map object to install.
        Throws:
        SQLException - In case of a database error.