日期:2014-05-16 浏览次数:20692 次
UserName=*** Password=***** jdbc.DriverClassName=com.mysql.jdbc.Driver jdbc.url=jdbc:mysql://localhost:3306/databaseName jdbc.username=${UserName} jdbc.password=${Password} jdbc.maxActive=10 jdbc.maxIdle=5 jdbc.maxWait=10000
<context:property-placeholder location="classpath:database.properties" /> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="url" value="${jdbc.url}" /> <property name="driverClassName" value="${jdbc.DriverClassName}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> <property name="maxActive" value="${jdbc.maxActive}" /> <property name="maxIdle" value="${jdbc.maxIdle}" /> <property name="maxWait" value="${jdbc.maxWait}" /> </bean> <!-- 声明iBatis模板类 --> <bean id="sqlMapClientTemplate" class="org.springframework.orm.ibatis.SqlMapClientTemplate"> <property name="sqlMapClient"> <bean class="org.springframework.orm.ibatis.SqlMapClientFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="configLocation" value="classpath:sqlMapConfig.xml" /> </bean> </property> </bean>
<?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> <settings cacheModelsEnabled="false" enhancementEnabled="true" lazyLoadingEnabled="true" useStatementNamespaces="true" /> <sqlMap resource="com/UserInfo.xml" /> </sqlMapConfig>