Defining the placeholder for connection url, Wiring of jdbc properties – HP Integrity NonStop J-Series User Manual

Page 64

Advertising
background image

Defining the placeholder for JDBC Type 2 Driver Class

Modify the applicationContext.xml file to define a placeholder for the JDBC Type 2 driver
class name com.tandem.sqlmx.SQLMXDriver from the jdbc.properties file as shown
below.

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClassName">
<value>${jdbc.driver}</value>
</property>

NOTE:

It is recommended to use com.mchange.v2.c3p0.ComboPooledDataSource as

the datasource class because it provides various parameters for connection pooling. In case you
do not use connection pooling, you can either use
org.apache.commons.dbcp.BasicDataSource

provided by Apache DBCP or

org.springframework.jdbc.datasource.DriverManagerDataSource

provided by

the Spring framework.

Defining the Placeholder for Connection URL

Modify the applicationContext.xml file to define a placeholder for the connection URL from
the jdbc.properties file as shown below.

<property name="url">
<value>${jdbc.url}</value>
</property>

Defining the Placeholder for Establishing the Connection

To establish the database connection, modify the applicationContext.xml file to define a
placeholder for the username and password from the jdbc.properties file as shown below.

<property name="username">
<value>${jdbc.user}</value>
</property>
<property name="password">
<value>${jdbc.password}</value>
</property>

Wiring of JDBC Properties

After all the database properties are set, wire the jdbc.properties file in the
applicationContext.xml

file so that the actual values are available during runtime. The

PropertyPlaceholderConfigurer

class provided by the Spring framework substitutes all

the database properties specified in the applicationContext.xml file with the values specified
in the jdbc.properties file during runtime.

Modify the applicationContext.xml file for wiring the jdbc.properties file as shown
below:

<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
</beans>

NOTE:

For information on the complete configuration snippet of the applicationContext.xml

file and the jdbc.properties file for JDBC Type 2 driver, see

“JDBC Configuration” (page 144)

.

64

Configuring Spring Applications on NonStop Systems

Advertising
This manual is related to the following products: