The persistence manager factory has a set of eight connection-related properties. These eight properties are unique to the PersistenceManagerFactory interface. They have overlapping purposes. Their use depends upon the design of the JDO implementation and the deployment environment of the application code. In some cases, the simple connection properties are the only ones required. Table 6-2 shows the four simple connection properties defined by JDO, together with a brief description of their purpose.
Property | Description |
---|---|
ConnectionDriverName | The class name of the connection driver |
ConnectionURL | The URL that the connection driver uses to connect to the datastore |
ConnectionUserName | The name of the user establishing the connection |
ConnectionPassword | The connection password for the user |
As described earlier, the JDO implementation can provide a JCA ConnectionFactory that produces persistence managers. The JDO implementation can also use JCA in a different way by having its PersistenceManager use a connection factory to connect to the datastore service. In this case, the JDO implementation supports the four connection factory properties. Table 6-3 shows the four connection factory properties defined by JDO, together with a brief description of their purpose.
Property | Description |
---|---|
ConnectionFactory | A connection factory object to connect to the datastore |
ConnectionFactoryName | The JNDI name for the connection factory object |
ConnectionFactory2 | A connection factory object suitable for JDO optimistic transactions |
ConnectionFactory2Name | The JNDI name for the connection factory object suitable for JDO optimistic transactions |
Within J2EE application servers, a connection factory that returns datastore connections normally returns connections that are enlisted in the active, managed transaction. This is not the connection to the datastore that a JDO optimistic transaction would use. For the application to be able to use a JDO optimistic transaction within a J2EE container, the persistence manager needs to use a connection factory that returns nontransactional datastore connections. The ConnectionFactory2 property holds the connection factory that returns nontransactional connections, and alternatively, the ConnectionFactory2Name specifies its JNDI name.
Because the connection properties overlap in their purposes, JDO defines a priority between them. If a connection factory is defined, then it is the controlling property. Failing that, if a JNDI name for a connection factory is defined, then it is the controlling property. Failing both of these, the simple connection properties are used. The implementation will likely provide specific guidance on which connection properties to configure.