iBatis2配置
 
1、iBatis的整体配置大概如下:
 
xml version ="1.0" encoding ="GBK" ?>
                "http://www.ibatis.com/dtd/sql-map-config-2.dtd">
< sqlMapConfig >
         < properties resource ="jdbc.properties" />
         < settings cacheModelsEnabled ="true" enhancementEnabled ="true"
                             lazyLoadingEnabled ="true" maxRequests ="512" maxSessions ="128"
                             maxTransactions ="32" useStatementNamespaces ="true" />

         < transactionManager type ="JDBC" commitRequired ="true" >
                
                 < property name ="" value="" />
                 < dataSource type ="SIMPLE" >
                         < property name ="JDBC.Driver" value ="${jdbc.driver}" />
                         < property name ="JDBC.ConnectionURL" value ="${jdbc.url}" />
                         < property name ="JDBC.Username" value ="${jdbc.user}" />
                         < property name ="JDBC.Password" value ="${jdbc.password}" />
                 dataSource >
         transactionManager >

         < sqlMap resource ="com/asiainfo/tdmc/entity/sqlmap/Cfg_code.xml" />

sqlMapConfig >
 
2、对每一段的解释
 
a、settings
         < settings
                
                cacheModelsEnabled="true"
                
                enhancementEnabled="true"
                
                lazyLoadingEnabled="true"
                
                maxRequests="512"
                
                maxSessions="128"
                
                maxTransactions="32"
                
                useStatementNamespaces="true"/>
 
b、事务管理器和数据源
         < transactionManager type ="JDBC" commitRequired ="true" >
                
                 < property name ="" value="" />
                 < dataSource type ="SIMPLE" >
                         < property name ="JDBC.Driver" value ="${jdbc.driver}" />
                         < property name ="JDBC.ConnectionURL" value ="${jdbc.url}" />
                         < property name ="JDBC.Username" value ="${jdbc.user}" />
                         < property name ="JDBC.Password" value ="${jdbc.password}" />
                 dataSource >
         transactionManager >
    
 
transactionManager配置内置的事务管理器,其type类型取值说明如下:
JDBC:基于JDBC的事务管理。
JTA:基于容器的事务管理。
EXTERNAL:提供非事务管理,并家丁管理事务的是应用程序,而不是iBatis
commitRequired是一个非必须的属性,默认为false,为true时要求在释放连接之前必须提交或者回滚操作。
dataSource是用来定义DataSourceFactory的实现类,其type类型取值说明如下:
SIMPLE:简单的数据源工厂,不要jdbc以外的jar包支持。
DBCP:使用jakarta Commons数据库连接池实现。
JNDI:通过JNDI定位的基于容器的数据源。