Jay
Jay

Reputation: 97

Inject Weblogic JDBC datasource (JNDI name) in spring applicationContext.xml

Currently, I am creating dataSource in spring applicationContext.xml by reading DB credentials from a property file.

<!-- property config -->     
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="location"><value>/WEBINF/resources/springConfig.properties</value></property>
    </bean> 

<!-- Database connection Oracle 10g jdbc -->
     <bean id="dataSource" class="oracle.jdbc.pool.OracleDataSource" destroy-method="close">
              <property name="URL"                     value="${url}" />
              <property name="user"                    value="${user}" />
              <property name="password"         value="${password}" />
              <property name="connectionCachingEnabled" value="true" />
       </bean>

Then i am referencing it using context.getBean

DataSource dataSource = (DataSource)context.getBean("dataSource");

I need to modify my applicationContext to create dataSource by not reading a property file but by using Weblogic JDBC datasource (I am not sure if its jndiTemplate or jdbcTemplate) Please provide an example and do i need to change the way i do getBean("dataSource") once i use the jndiTemplate?

Upvotes: 2

Views: 9274

Answers (1)

duffymo
duffymo

Reputation: 308948

You want to do a JNDI datasource lookup. Here's an example:

http://middlewaremagic.com/weblogic/?p=5106

Upvotes: 1

Related Questions