ibatis配置

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE sqlMapConfig      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">
<sqlMapConfig>
	<properties resource="sqlmap.properties" />
	<settings cacheModelsEnabled="true" enhancementEnabled="true" lazyLoadingEnabled="true" maxRequests="32" maxSessions="10" maxTransactions="5"
		useStatementNamespaces="true" />
	<transactionManager type="JDBC">
		<dataSource type="SIMPLE">
			<property name="JDBC.Driver" value="${jdbc.driverClassName}" />
			<property name="JDBC.ConnectionURL" value="${jdbc.url}" />
			<property name="JDBC.Username" value="${jdbc.username}" />
			<property name="JDBC.Password" value="${jdbc.password}" />
			<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 sample" />
			<property name="Pool.PingEnabled" value="false" />
			<property name="Pool.PingConnectionsOlderThan" value="1" />
			<property name="Pool.PingConnectionsNotUsedFor" value="1" />
		</dataSource>
	</transactionManager>
	<sqlMap resource="byd/entity/xml/DpPo.xml" />
	<sqlMap resource="byd/entity/xml/dpt.xml" />
	<sqlMap resource="byd/entity/xml/Supplier.xml" />
	<sqlMap resource="byd/entity/xml/Judge.xml" />
	<sqlMap resource="byd/entity/xml/his.xml" />
</sqlMapConfig>
 
sqlmap.properties

jdbc.driverClassName=oracle.jdbc.driver.OracleDriver
jdbc.url=jdbc\:oracle\:thin\:@10.6.78.244\:1521\:denali  
jdbc.username=scmdp  
jdbc.password=scmdp  
 
package byd.core;

import java.io.IOException;
import java.io.Reader;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

public class BaseDao {
	private static SqlMapClient sqlMapper;
	public static synchronized SqlMapClient getSqlmap() {
		if (sqlMapper == null) {
			try {
				Reader reader = Resources.getResourceAsReader("SqlMapConfig.xml");
				sqlMapper = SqlMapClientBuilder.buildSqlMapClient(reader);
				reader.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return sqlMapper;
	}

}
 
posted @ 2011-07-21 14:26  上善¤若水  阅读(134)  评论(0编辑  收藏  举报