jlm
Aug 16th, 2004, 12:57 PM
I'm having a hard time getting started. I am trying to use the spring jdbc in a existing program. I am getting java.lang.IllegalArgumentException: dataSource is required error. I know if I can just get started, using spring's jdbc support will correct the problems we are having with leaked connections.
<web-app id="WebApp">
<display-name>SanctionedProviderWeb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServl et</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer">
<property name="location"><value>/WEB-INF/jdbc.properties</value></property>
</bean>
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>jdbc/xep</value></property>
</bean>
<bean id="letterDao" class="com.wellpoint.xep.dao.LetterDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
<bean id="providerDao" class="com.wellpoint.xep.dao.ProviderDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
<bean id="sanctionDao" class="com.wellpoint.xep.dao.SanctionDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
</beans>
public class ProviderDaoImpl implements ProviderDao {
private DataSource dataSource;
private List List;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
public List getMonths() throws DataAccessException {
final List months = new ArrayList();
setDataSource(dataSource);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.queryForList("Select Distinct Month(STPR_MTCH_RPT_DT) RptMonth, Year(STPR_MTCH_RPT_DT) RptYear "
+ "from XEP.Stpr_Snctn_Prov");
return months;
}
<web-app id="WebApp">
<display-name>SanctionedProviderWeb</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServl et</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<beans>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyP laceholderConfigurer">
<property name="location"><value>/WEB-INF/jdbc.properties</value></property>
</bean>
<!-- Message source for this context, loaded from localized "messages_xx" files -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundle MessageSource">
<property name="basename"><value>messages</value></property>
</bean>
<bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName"><value>jdbc/xep</value></property>
</bean>
<bean id="letterDao" class="com.wellpoint.xep.dao.LetterDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
<bean id="providerDao" class="com.wellpoint.xep.dao.ProviderDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
<bean id="sanctionDao" class="com.wellpoint.xep.dao.SanctionDaoImpl">
<property name="dataSource"><ref local="myDataSource"/></property>
</bean>
</beans>
public class ProviderDaoImpl implements ProviderDao {
private DataSource dataSource;
private List List;
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
public List getMonths() throws DataAccessException {
final List months = new ArrayList();
setDataSource(dataSource);
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
jdbcTemplate.queryForList("Select Distinct Month(STPR_MTCH_RPT_DT) RptMonth, Year(STPR_MTCH_RPT_DT) RptYear "
+ "from XEP.Stpr_Snctn_Prov");
return months;
}