com.ibm.as400.access

Class AS400JDBCObjectFactory

  • java.lang.Object
    • com.ibm.as400.access.AS400JDBCObjectFactory
  • All Implemented Interfaces:
    javax.naming.spi.ObjectFactory


    public class AS400JDBCObjectFactory
    extends java.lang.Object
    implements javax.naming.spi.ObjectFactory
    The AS400JDBCObjectFactory is used by a JNDI service provider to reconstruct an object when it is retrieved from JNDI.

    When constructing your own Reference object, at a minimum, you should set the serverName, userName, pwd, and secure properties.

    For Example:

      XADataSource xads = null; 
      String objFactoryName = "com.ibm.as400.access.AS400JDBCObjectFactory";
      String xadsName = "com.ibm.as400.access.AS400JDBCXADataSource";
      Reference ref = new Reference(xadsName, objFactoryName, "");
      ref.add(new StringRefAddr("serverName", "someserver"));
      ref.add(new StringRefAddr("userName", "someuser"));
      ref.add(new StringRefAddr("pwd", "somepassword"));
      ref.add(new StringRefAddr("secure", "false"));
      ref.add(new StringRefAddr("trace", "true"));
      try {
          ObjectFactory objectFactory = (ObjectFactory)Class.forName(objFactoryName).newInstance();
          xads = (XADataSource)objectFactory.getObjectInstance(ref, null, null, null);
          XAConnection xacon = xads.getXAConnection();
          Connection con = xacon.getConnection();
      } catch (Exception ex) {
          ex.printStackTrace();
          System.err.println("Exception caught: " + ex);
      }
      
    The following classes implement the javax.naming.Referenceable interface.
    See Also:
    AS400JDBCDataSource, AS400JDBCConnectionPoolDataSource
    • Method Summary

      Methods 
      Modifier and Type Method and Description
      java.lang.Object getObjectInstance(java.lang.Object referenceObject, javax.naming.Name name, javax.naming.Context nameContext, java.util.Hashtable environment)
      Returns the object requested.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AS400JDBCObjectFactory

        public AS400JDBCObjectFactory()
    • Method Detail

      • getObjectInstance

        public java.lang.Object getObjectInstance(java.lang.Object referenceObject,
                                         javax.naming.Name name,
                                         javax.naming.Context nameContext,
                                         java.util.Hashtable environment)
                                           throws java.lang.Exception
        Returns the object requested.
        Specified by:
        getObjectInstance in interface javax.naming.spi.ObjectFactory
        Parameters:
        referenceObject - The object reference.
        name - The object name.
        nameContext - The context of the name.
        environment - The environment.
        Returns:
        The object requested.
        Throws:
        java.lang.Exception - If an error occurs during object creation.