RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:9:30-18:00
你可能遇到了下面的问题
关闭右侧工具栏
Ibatis2.0使用说明(二)——配置篇(1)[原]
  • 作者:xiaoxiao
  • 发表时间:2020-12-23 11:03
  • 来源:未知

一、 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 configfile (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>