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

Page 66

Advertising
background image

<value>${jdbc.driver}</value>
</property>

NOTE:

It is recommended that you use com.mchange.v2.c3p0.ComboPooledDataSource

as the datasource class because it provides various parameters for connection pooling. Other
available datasource classes are org.apache.commons.dbcp.BasicDataSource provided
by Apache DBCP and
org.springframework.jdbc.datasource.DriverManagerDataSource

provided by

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

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 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 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, see

“JDBC Configuration” (page 144)

.

Configuring Database Transaction Management

Spring framework provides the following ways for configuring transaction management:

Declarative Transaction Management: In this case, the transaction action is defined in an XML
configuration file for each method (or class).

Programmatic Transaction Management: In this case, the transaction action is hardcoded in
the code. This is similar to the JDBC transaction.

66

Configuring Spring Applications on NonStop Systems

Advertising
This manual is related to the following products: