当前位置: 代码迷 >> SQL >> iBATIS SQL Map (二)
  详细解决方案

iBATIS SQL Map (二)

热度:38   发布时间:2016-05-05 13:07:15.0
iBATIS SQL Map (2)
SQL Map XML配置文件
SQL Map使用XML配置文件统一配置不同的属性,包括DataSource的详细配置信息,SQL Map和其他可选属性,如线程管理等。以下是SQL Map配置文件的一个例子:
SqlMapConfig.xml
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE sqlMapConfigPUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN""http://www.ibatis.com/dtd/sql-map-config-2.dtd"><!-- Always ensure to use the correct XML header as above! --><sqlMapConfig><!-- The properties (name=value) in the file specified here can be used placeholders in this config file (e.g. “${driver}”. The file is relative to the classpath and is completely optional. --><properties resource=" examples/sqlmap/maps/SqlMapConfigExample.properties " /><!-- These settings control SqlMapClient configuration details, primarily to do with transactionmanagement. They are all optional (more detail later in this document). --><settingscacheModelsEnabled="true"enhancementEnabled="true"lazyLoadingEnabled="true"maxRequests="32"maxSessions="10"maxTransactions="5"useStatementNamespaces="false"/><!-- Type aliases allow you to use a shorter name for long fully qualified class names. --><typeAlias alias="order" type="testdomain.Order"/><!-- Configure a datasource to use with this SQL Map using SimpleDataSource.Notice the use of the properties from the above resource --><transactionManager type="JDBC" ><dataSource type="SIMPLE"><property name="JDBC.Driver" value="${driver}"/><property name="JDBC.ConnectionURL" value="${url}"/><property name="JDBC.Username" value="${username}"/><property name="JDBC.Password" value="${password}"/><property name="JDBC.DefaultAutoCommit" value="true" /><property name="Pool.MaximumActiveConnections" value="10"/><property name="Pool.MaximumIdleConnections" value="5"/><property name="Pool.MaximumCheckoutTime" value="120000"/><property name="Pool.TimeToWait" value="500"/><property name="Pool.PingQuery" value="select 1 from ACCOUNT"/><property name="Pool.PingEnabled" value="false"/><property name="Pool.PingConnectionsOlderThan" value="1"/><property name="Pool.PingConnectionsNotUsedFor" value="1"/></dataSource></transactionManager><!-- Identify all SQL Map XML files to be loaded by this SQL map. Notice the pathsare relative to the classpath. For now, we only have one… --><sqlMap resource="examples/sqlmap/maps/Person.xml" /></sqlMapConfig>

以下详细讨论SQL Map配置文件的各组成部分。
  相关解决方案