Class AbstractDataSource

    • Constructor Detail

      • AbstractDataSource

        public AbstractDataSource​(ManagedConnectionFactoryImpl mcf,
                                  jakarta.resource.spi.ConnectionManager cm)
        Constructs DataSource object. This is created by the ManagedConnectionFactory object.
        Parameters:
        mcf - ManagedConnectionFactory object creating this object.
        cm - ConnectionManager object either associated with Application server or Resource Adapter.
    • Method Detail

      • getConnection

        public Connection getConnection​(Connection con)
                                 throws SQLException
        Retrieves the actual SQLConnection from the Connection wrapper implementation of SunONE application server. If an actual connection is supplied as argument, then it will be just returned.
        Specified by:
        getConnection in interface DataSource
        Parameters:
        con - Connection obtained from Datasource.getConnection()
        Returns:
        java.sql.Connection implementation of the driver.
        Throws:
        SQLException - if connection cannot be obtained.
      • getNonTxConnection

        public Connection getNonTxConnection()
                                      throws SQLException
        Gets a connection that is not in the scope of any transaction. This can be used to save performance overhead incurred on enlisting/delisting each connection got, irrespective of whether its required or not. Note here that this meethod does not fit in the connector contract per se.
        Specified by:
        getNonTxConnection in interface DataSource
        Returns:
        java.sql.Connection
        Throws:
        SQLException - if connection cannot be obtained
      • getNonTxConnection

        public Connection getNonTxConnection​(String user,
                                             String password)
                                      throws SQLException
        Gets a connection that is not in the scope of any transaction. This can be used to save performance overhead incurred on enlisting/delisting each connection got, irrespective of whether its required or not. Note here that this meethod does not fit in the connector contract per se.
        Specified by:
        getNonTxConnection in interface DataSource
        Parameters:
        user - User name for authenticating the connection
        password - Password for authenticating the connection
        Returns:
        java.sql.Connection
        Throws:
        SQLException - if connection cannot be obtained
      • getDescription

        public String getDescription()
        Retrieves the description.
        Returns:
        Description about the DataSource.
      • setDescription

        public void setDescription​(String description)
        Set the description.
        Parameters:
        description - Description about the DataSource.
      • setReference

        public void setReference​(Reference reference)
        Get the reference.
        Specified by:
        setReference in interface jakarta.resource.Referenceable
        Parameters:
        reference - Reference object.
      • markConnectionAsBad

        public void markConnectionAsBad​(Connection conn)
        API to mark a connection as bad. If the application can determine that the connection is bad, using this api, it can notify the resource-adapter which inturn will notify the connection-pool. Connection-pool will drop and create a new connection. eg:
                com.sun.appserv.jdbc.DataSource ds=
                   (com.sun.appserv.jdbc.DataSource)context.lookup("dataSource");
                        Connection con = ds.getConnection();
                        Statement stmt = null;
                        try{
                                 stmt = con.createStatement();
                                 stmt.executeUpdate("Update");
                        }catch(BadConnectionException e){
                                dataSource.markConnectionAsBad(con) //marking it as bad for removal
                        }finally{
                                stmt.close();
                                con.close(); //Connection will be destroyed while close or Tx completion
                    }
         
        Specified by:
        markConnectionAsBad in interface DataSource
        Parameters:
        conn - java.sql.Connection