public class AS400JDBCObjectFactory
extends java.lang.Object
implements javax.naming.spi.ObjectFactory
When constructing your own Reference object, at a minimum, you should set the serverName, userName, pwd, and secure properties.
For Example:
The following classes implement the javax.naming.Referenceable interface.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); }
Constructor and Description |
---|
AS400JDBCObjectFactory() |
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.
|
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
getObjectInstance
in interface javax.naming.spi.ObjectFactory
referenceObject
- The object reference.name
- The object name.nameContext
- The context of the name.environment
- The environment.java.lang.Exception
- If an error occurs during object creation.