SQLMap XML配置文件

SQLMap使用XML配置文件统一配置不同的属性,包括DataSource的详细配置信息,
SQLMap和其他可选属性,如线程管理等。以下是SQLMap配置文件的一个例子:
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig
PUBLIC "-//iBATIS.com//DTD SQL Map Config2.0//EN"
"http://www.ibatis.com/dtd/sql-map-config-2.dtd">
<!-- Alwaysensure touse the correct XMLheader as above!-->
<sqlMapConfig>
<!-- Theproperties (name=value) inthe file specifiedhere canbeusedplaceholders inthis
config file (e.g. “${driver}”. The file is relativeto the classpath and is completelyoptional.-->
<properties resource=" examples/sqlmap/maps/SqlMapConfigExample.properties " />
<!-- These settingscontrol SqlMapClientconfiguration details, primarilytodo withtransaction
management. Theyareall optional (moredetail later in thisdocument). -->
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="true"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="false"
/>
<!-- Typealiases allowyoutouse a shorter name for longfullyqualifiedclass names. -->
<typeAliasalias="order" type="testdomain.Order"/>
<!-- Configureadatasource to use withthisSQL Map using SimpleDataSource.
Notice the use ofthe properties fromthe above resource -->
<transactionManager type="JDBC" >
<dataSource type="SIMPLE">
<propertyname="JDBC.Driver" value="${driver}"/>
<propertyname="JDBC.ConnectionURL" value="${url}"/>
<propertyname="JDBC.Username" value="${username}"/>
<propertyname="JDBC.Password" value="${password}"/>
<propertyname="JDBC.DefaultAutoCommit" value="true"/>
<propertyname="Pool.MaximumActiveConnections" value="10"/>
<propertyname="Pool.MaximumIdleConnections" value="5"/>
<propertyname="Pool.MaximumCheckoutTime" value="120000"/>
<propertyname="Pool.TimeToWait" value="500"/>
<propertyname="Pool.PingQuery" value="select1from ACCOUNT"/>
<propertyname="Pool.PingEnabled" value="false"/>
<propertyname="Pool.PingConnectionsOlderThan" value="1"/>
<propertyname="Pool.PingConnectionsNotUsedFor" value="1"/>
</dataSource>
</transactionManager>
<!-- Identifyall SQL Map XML files to be loadedbythis SQLmap.Notice the paths
are relativetothe classpath.Fornow, we onlyhaveone… -->
<sqlMapresource="examples/sqlmap/maps/Person.xml" />
</sqlMapConfig>

猜你喜欢

转载自kafeige.iteye.com/blog/1706766
今日推荐