0

In weblogic 10.3.6 server, I have defined the as400 datasource and now I am using myEclipse with java spring framework to develop program to access as400 db by using namedParameterjdbctemplate. I have the sql for as400 select statement. I have below xml code defined in applicationContext.xml in my project. Is there a way to use jdbcParameterNamedTemplate to function as I know jdbcTemplate need to have datasource which will have connection string or password and I not want to enter these values in code but still use weblogic datasource? Is there any example??

<beans>
  <bean id="AS400UATJdbcTemplate" class="org.springframework.jndi.JndiObjectFactoryBean">
  <property name="jndiName" value="AS400UAT"/>
  <property name="lookupOnStartup" value="false"/>
  <property name="cache" value="true"/>
  <property name="proxyInterface" value="javax.sql.DataSource"/>
  </bean>

<bean id="getCreditCardByAccountsNumeStoredProcedure" class="com.as400function.GetAccountsByTypeStoredProcedure" singleton="false">
  <constructor-arg>
  <ref bean="AS400UATJdbcTemplate"/>
  </constructor-arg>
  </bean>


  <bean id="AddSingleWithCreditCard" class="com.as400function.AddSingleWithCreditCard" singleton="false">
        <constructor-arg>
            <ref bean="AS400UATJdbcTemplate"/>
        </constructor-arg>
    </bean>
</beans>
1
  • It solved with below answer Commented Aug 3, 2017 at 2:35

1 Answer 1

0

I have amended the applicationContext.xml

<bean id="AS400ForOct" class="org.springframework.jndi.JndiObjectFactoryBean">
        <property name="jndiName" value="AS400UAT"/>
    </bean>

    <bean id="getCreditCardByAccountsNumeStoredProcedure" class="com.aeon.awip.membersite.as400function.GetCreditCardByAccountsNumeStoredProcedure" singleton="false">
          <property name="dataSource">
            <ref bean="AS400ForOct" />
        </property>
    </bean>

Amended the Class file of constructor:

public class GetCreditCardByAccountsNumeStoredProcedure extends JdbcDaoSupport{
    public GetOctopusCreditCardByAccountsNumeStoredProcedure (DataSource datasource){
        setDataSource(datasource);
    }
    public GetOctopusCreditCardByAccountsNumeStoredProcedure() {
        super();
    }
.......
}

Add below code to call

ApplicationContext ctx = ServiceLocator.getApplicationContext();
            getCreditCardByAccountsNumeStoredProcedure = (GetCreditCardByAccountsNumeStoredProcedure)ctx.getBean("getCreditCardByAccountsNumeStoredProcedure");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.