你的位置:首页 > 软件开发 > Java > Ibatis学习总结2

Ibatis学习总结2

发布时间:2016-01-03 00:00:23
SQL Map 使用 1 <??> 2 3 <!DOCTYPE sqlMapConfig 4 5 PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http:/ ...

SQL Map 使用 

 1 <??> 2  3 <!DOCTYPE sqlMapConfig 4  5 PUBLIC "-//iBATIS.com//DTD SQL Map Config 2.0//EN" "http://www.ibatis.com/dtd/sql-map-config-2.dtd"> 6 <!-- Always ensure to use the correct --> 7  8 <sqlMapConfig> 9 10 <!-- 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. -->11 <properties resource=" examples/sqlmap/maps/SqlMapConfigExample.properties " />12 13 14 <!-- These settings control SqlMapClient configuration details, primarily to do with transaction management. They are all optional (more detail later in this document). -->15 <settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="32" maxSessions="10" maxTransactions="5"16 useStatementNamespaces="false"17 18 />19 20 <!-- Type aliases allow you to use a shorter name for long fully qualified class names. -->21 22 <typeAlias alias="order" type="testdomain.Order"/>23 24 25 <!-- Configure a datasource to use with this SQL Map using SimpleDataSource. Notice the use of the properties from the above resource -->26 <transactionManager type="JDBC" >27 28 <dataSource type="SIMPLE">29 30 <property name="JDBC.Driver" value="${driver}"/>31 32 <property name="JDBC.ConnectionURL" value="${url}"/>33 34 <property name="JDBC.Username" value="${username}"/>35 36 <property name="JDBC.Password" value="${password}"/>37 38 <property name="JDBC.DefaultAutoCommit" value="true" />39 40 <property name="Pool.MaximumActiveConnections" value="10"/>41 42 43 44 <property name="Pool.MaximumIdleConnections" value="5"/>45 46 <property name="Pool.MaximumCheckoutTime" value="120000"/>47 48 <property name="Pool.TimeToWait" value="500"/>49 50 <property name="Pool.PingQuery" value="select 1 from ACCOUNT"/>51 52 <property name="Pool.PingEnabled" value="false"/>53 54 <property name="Pool.PingConnectionsOlderThan" value="1"/>55 56 <property name="Pool.PingConnectionsNotUsedFor" value="1"/>57 58 </dataSource>59 60 </transactionManager>61 62 63 <!-- Identify all SQL Map -->64 <sqlMap resource="examples/sqlmap/maps/Person. />65 66 </sqlMapConfig>

JndiDataSourceFactory

JndiDataSourceFactory 在应用容器内部从 JNDI Context 中查找 DataSource 实现。当使用 应用服务器,并且服务器提供了容器管理的连接池和相关 DataSource 实现的情况下,可以 使用 JndiDataSourceFactory。使用 JDBC  DataSource  的标准方法是通过 JNDI  来查找。 JndiDataSourceFactory 必须要配置的属性如下:

1 <transactionManager type="JDBC" >2 <dataSource type="JNDI">3 <property name="DataSource" value="java:comp/env/jdbc/jpetstore"/>4 </dataSource>5 </transactionManager>

原标题:Ibatis学习总结2

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录