Java Reference
In-Depth Information
Let's see how to apply them in our view category example in order to retrieve our
product list.
SQLMap configuration
We will use sql-map-config.xml to specify database properties, set up the transac-
tion manager, and tie together all of the SQLmap files (see listing 14.16). The
<properties> tag will point to a file that contains key/value
pairs that are used to substitute the items written as ${…} . We should make sure
that our file contains the appropriate driver, URL , user-
name, and password for the chosen database.
Listing 14.16
SQLMAP transaction manager configuration
<properties resource="properties/"/>
<transactionManager type="JDBC">
<dataSource type="SIMPLE">
<property value="${driver}" name="JDBC.Driver"/>
<property value="${url}" name="JDBC.ConnectionURL"/>
<property value="${username}" name="JDBC.Username"/>
<property value="${password}" name="JDBC.Password"/>
<sqlMap resource= ~CCC
Next, we'll move on to configuring our transaction manager. For our purposes,
we will use the easiest transaction manager type of JDBC . The JDBC type specifies
that the SQLMap will use the standard Connection object commit and rollback
methods. Since we are handling the transaction demarcation on the service layer,
this configuration is more important. However, this transaction manager configu-
ration is required in order for the transaction manager configured with i BATIS
DAO to work correctly.
The data source inside the transactionManager defines the JDBC data source
that the transaction manager will use to retrieve connections. We specify a type of
SIMPLE because we will have i BATIS handling the data source connection pool.
The <property> tag is then used to specify the driver, connection URL , username,
and password. Each <property> tag uses the ${…} notation and retrieves values
from the file.
Search WWH ::

Custom Search