Class ConnectionHolder40

    • Field Detail

      • localStrings

        protected static final StringManager localStrings
      • defaultClientInfo

        protected Properties defaultClientInfo
    • Constructor Detail

      • ConnectionHolder40

        public ConnectionHolder40​(Connection con,
                                  ManagedConnectionImpl mc,
                                  jakarta.resource.spi.ConnectionRequestInfo cxRequestInfo)
        Connection wrapper given to application program
        Parameters:
        con - Connection that is wrapped
        mc - ManagedConnection
        cxRequestInfo - Connection Request Information
    • Method Detail

      • init

        protected void init()
        cache the default client info which can will set back during close()
        as this connection may be re-used by connection pool of application server
      • createClob

        public Clob createClob()
                        throws SQLException
        Constructs an object that implements the Clob interface. The object returned initially contains no data. The setAsciiStream, setCharacterStream and setString methods of the Clob interface may be used to add data to the Clob.
        Returns:
        An object that implements the Clob interface
        Throws:
        SQLException - if an object that implements the Clob interface can not be constructed, this method is called on a closed connection or a database access error occurs.
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • createBlob

        public Blob createBlob()
                        throws SQLException
        Constructs an object that implements the Blob interface. The object returned initially contains no data. The setBinaryStream and setBytes methods of the Blob interface may be used to add data to the Blob.
        Returns:
        An object that implements the Blob interface
        Throws:
        SQLException - if an object that implements the Blob interface can not be constructed, this method is called on a closed connection or a database access error occurs.
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • createNClob

        public NClob createNClob()
                          throws SQLException
        Constructs an object that implements the NClob interface. The object returned initially contains no data. The setAsciiStream, setCharacterStream and setString methods of the NClob interface may be used to add data to the NClob.
        Returns:
        An object that implements the NClob interface
        Throws:
        SQLException - if an object that implements the NClob interface can not be constructed, this method is called on a closed connection or a database access error occurs.
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • createSQLXML

        public SQLXML createSQLXML()
                            throws SQLException
        Constructs an object that implements the SQLXML interface. The object returned initially contains no data. The createXmlStreamWriter object and setString method of the SQLXML interface may be used to add data to the SQLXML object.
        Returns:
        An object that implements the SQLXML interface
        Throws:
        SQLException - if an object that implements the SQLXML interface can not be constructed, this method is called on a closed connection or a database access error occurs.
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • isValid

        public boolean isValid​(int timeout)
                        throws SQLException
        Returns true if the connection has not been closed and is still valid. The driver shall submit a query on the connection or use some other mechanism that positively verifies the connection is still valid when this method is called.

        The query submitted by the driver to validate the connection shall be executed in the context of the current transaction.

        Parameters:
        timeout - The time in seconds to wait for the database operation used to validate the connection to complete. If the timeout period expires before the operation completes, this method returns false. A value of 0 indicates a timeout is not applied to the database operation.
        Returns:
        true if the connection is valid, false otherwise
        Throws:
        SQLException - if the value supplied for timeout is less then 0
        Since:
        1.6
        See Also:
        DatabaseMetaData.getClientInfoProperties()
      • setClientInfo

        public void setClientInfo​(String name,
                                  String value)
                           throws SQLClientInfoException
        Sets the value of the client info property specified by name to the value specified by value.

        Applications may use the DatabaseMetaData.getClientInfoProperties method to determine the client info properties supported by the driver and the maximum length that may be specified for each property.

        The driver stores the value specified in a suitable location in the database. For example in a special register, session parameter, or system table column. For efficiency the driver may defer setting the value in the database until the next time a statement is executed or prepared. Other than storing the client information in the appropriate place in the database, these methods shall not alter the behavior of the connection in anyway. The values supplied to these methods are used for accounting, diagnostics and debugging purposes only.

        The driver shall generate a warning if the client info name specified is not recognized by the driver.

        If the value specified to this method is greater than the maximum length for the property the driver may either truncate the value and generate a warning or generate a SQLClientInfoException. If the driver generates a SQLClientInfoException, the value specified was not set on the connection.

        The following are standard client info properties. Drivers are not required to support these properties however if the driver supports a client info property that can be described by one of the standard properties, the standard property name should be used.

        • ApplicationName - The name of the application currently utilizing the connection
        • ClientUser - The name of the user that the application using the connection is performing work for. This may not be the same as the user name that was used in establishing the connection.
        • ClientHostname - The hostname of the computer the application using the connection is running on.
        Parameters:
        name - The name of the client info property to set
        value - The value to set the client info property to. If the value is null, the current value of the specified property is cleared.
        Throws:
        SQLClientInfoException - if the database server returns an error while setting the client info value on the database server or this method is called on a closed connection
        Since:
        1.6
      • setClientInfo

        public void setClientInfo​(Properties properties)
                           throws SQLClientInfoException
        Sets the value of the connection's client info properties. The Properties object contains the names and values of the client info properties to be set. The set of client info properties contained in the properties list replaces the current set of client info properties on the connection. If a property that is currently set on the connection is not present in the properties list, that property is cleared. Specifying an empty properties list will clear all of the properties on the connection. See setClientInfo (String, String) for more information.

        If an error occurs in setting any of the client info properties, a SQLClientInfoException is thrown. The SQLClientInfoException contains information indicating which client info properties were not set. The state of the client information is unknown because some databases do not allow multiple client info properties to be set atomically. For those databases, one or more properties may have been set before the error occurred.

        Parameters:
        properties - the list of client info properties to set
        Throws:
        SQLClientInfoException - if the database server returns an error while setting the clientInfo values on the database server or this method is called on a closed connection
        Since:
        1.6
        See Also:
        setClientInfo(String, String)
      • getClientInfo

        public String getClientInfo​(String name)
                             throws SQLException
        Returns the value of the client info property specified by name. This method may return null if the specified client info property has not been set and does not have a default value. This method will also return null if the specified client info property name is not supported by the driver.

        Applications may use the DatabaseMetaData.getClientInfoProperties method to determine the client info properties supported by the driver.

        Parameters:
        name - The name of the client info property to retrieve
        Returns:
        The value of the client info property specified
        Throws:
        SQLException - if the database server returns an error when fetching the client info value from the database or this method is called on a closed connection
        Since:
        1.6
        See Also:
        DatabaseMetaData.getClientInfoProperties()
      • getClientInfo

        public Properties getClientInfo()
                                 throws SQLException
        Returns a list containing the name and current value of each client info property supported by the driver. The value of a client info property may be null if the property has not been set and does not have a default value.
        Returns:
        A Properties object that contains the name and current value of each of the client info properties supported by the driver.
        Throws:
        SQLException - if the database server returns an error when fetching the client info values from the database or this method is called on a closed connection
        Since:
        1.6
      • createArrayOf

        public Array createArrayOf​(String typeName,
                                   Object[] elements)
                            throws SQLException
        Factory method for creating Array objects.
        Parameters:
        typeName - the SQL name of the type the elements of the array map to. The typeName is a database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database. This is the value returned by Array.getBaseTypeName
        elements - the elements that populate the returned object
        Returns:
        an Array object whose elements map to the specified SQL type
        Throws:
        SQLException - if a database error occurs, the typeName is null or this method is called on a closed connection
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • createStruct

        public Struct createStruct​(String typeName,
                                   Object[] attributes)
                            throws SQLException
        Factory method for creating Struct objects.
        Parameters:
        typeName - the SQL type name of the SQL structured type that this Struct object maps to. The typeName is the name of a user-defined type that has been defined for this database. It is the value returned by Struct.getSQLTypeName.
        attributes - the attributes that populate the returned object
        Returns:
        a Struct object that maps to the given SQL type and is populated with the given attributes
        Throws:
        SQLException - if a database error occurs, the typeName is null or this method is called on a closed connection
        SQLFeatureNotSupportedException - if the JDBC driver does not support this data type
        Since:
        1.6
      • unwrap

        public <T> T unwrap​(Class<T> iface)
                     throws SQLException
        Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

        If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an SQLException is thrown.

        Parameters:
        iface - A Class defining an interface that the result must implement.
        Returns:
        an object that implements the interface. May be a proxy for the actual implementing object.
        Throws:
        SQLException - If no object found that implements the interface
        Since:
        1.6
      • isWrapperFor

        public boolean isWrapperFor​(Class<?> iface)
                             throws SQLException
        Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.
        Parameters:
        iface - a Class defining an interface.
        Returns:
        true if this implements the interface or directly or indirectly wraps an object that does.
        Throws:
        SQLException - if an error occurs while determining whether this is a wrapper for an object with the given interface.
        Since:
        1.6
      • abort

        public void abort​(Executor executor)
                   throws SQLException
        Abort operation to mark the connection internally as a bad connection for removal and to close the connection. This ensures that at the end of the transaction, the connection is destroyed. A running thread holding a connection will run to completion before the connection is destroyed
        Parameters:
        executor -
        Throws:
        SQLException