Configuring a JNDI datasource

The jndi-configuration section of the mcs-config.xml file contains the definition of a configuration of one or more JNDI datasources. You can refer to this definition when you specify a jndi-data-source element in the local-repository section of the configuration file.

The jndi-configuration section of the mcs-config.xml file contains the definition of a configuration of one or more JNDI datasources. You can refer to this definition when you specify a jndi-data-source element in the local-repository section of the configuration file.

The name attribute on the initial-context element defines the starting context for resolving JNDI names. The parameter element allows you to specify any name/value pairs required by a particular JNDI service.

<jndi-configuration>
  <initial-context name="myContext">
    <parameter
      name="java.naming.factory.initial"
      value="com.ibm.websphere.naming.WsnInitialContextFactory"/>
  </initial-context>
</jndi-configuration>

The next listing shows a matching local-repository entry. The initial-context attribute on the jndi-data-source element must match the name of the name attribute on the initial-context element defined in the jndi-configuration. The name attribute sets the name of the data source within the initial context.

<local-repository>
  <jdbc-repository>
    <anonymous-data-source
      user="[user]"
      password="[password]">
      <jndi-data-source
        initial-context="myContext"
        name="datasourceName"/>
    </anonymous-data-source>
  </jdbc-repository>
<local-repository>

Related topics