Class AS400JDBCObjectFactory

  • java.lang.Object
  • All Implemented Interfaces:

    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 = "";
      String xadsName = "";
      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) {
          System.err.println("Exception caught: " + ex);
    The following classes implement the javax.naming.Referenceable interface.
    See Also:
    AS400JDBCDataSource, AS400JDBCConnectionPoolDataSource
    • Method Summary

      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
        referenceObject - The object reference.
        name - The object name.
        nameContext - The context of the name.
        environment - The environment.
        The object requested.
        java.lang.Exception - If an error occurs during object creation.