Manual
2. Create a new XML file in the EmpInfo/WebContent/WEB-INF directory and enter the
name of the XML file as applicationContext.
NOTE: By default, XML files open in the XML Editor. The XML Editor has two views:
Design and Source view. Select the Source view.
3. Modify the applicationContext.xml file to add a bean definition of the EmployeeDao
class. After modification, the applicationContext.xml file must appear as:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
destroy-method="close">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>
<property name="url">
<value>${jdbc.url}</value>
</property>
<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>
<property name="connectionProperties">
<props>
<prop key="catalog">
${jdbc.catalog}
</prop>
<prop key="schema">
${jdbc.schema}
</prop>
</props>
</property>
</bean>
<bean id="empdao" class="com.hp.empinfo.service.EmployeeDao">
<property name="dataSource">
<ref bean="dataSource" />
</property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="/WEB-INF/jdbc.properties"/>
</bean>
</beans>
Creating the jdbc.properties File
The JdbcDaoSupport feature of Spring framework is used for connecting to the NonStop SQL/MX
database and for carrying out requested database transactions. To fulfill this requirement, the
jdbc.properties file must be created to include all the database related information.
To create the jdbc.properties file, complete the following steps:
1. On the Project Explorer frame, right-click EmpInfo and select New > File.
The New File dialog box appears.
2. In the File name field, enter jdbc.properties and ensure that the parent folder is set to
the EmpInfo/WebContent/WEB-INF directory. Click Finish.
Figure 5-24 shows the New File dialog box.
122 Getting Started with Spring