Setting up a JNDI Data Source in Spring

Just put something like this in your applicationContext.xml

 <bean id=”appDS” class=”org.springframework.jndi.JndiObjectFactoryBean”>
  <property name=”jndiEnvironment”>
      <props>
        <prop key=”java.naming.factory.initial”>weblogic.jndi.WLInitialContextFactory</prop>
        <prop key=”java.naming.provider.url”>t3://localhost</prop>
      </props>
    </property>
    <property name=”jndiName” value=”datasourcejndi_name”>
  </property>
</bean>
You’re properties and jndiName will probably be different.  But still — no code, just configuration. It doesn’t get much better than that!

Powered by ScribeFire.

Leave a Reply

You must be logged in to post a comment.