datasource.properties
db.jdbcurl=jdbc:oracle:thin:@xxx.xxx.xx.xx:1521:orcl
#db.jdbcurl=jdbc:mysql://xx.xx.xx.xx:3306/portalms#db.user=xxx
#db.password=xxx
db.driverclass=oracle.jdbc.driver.OracleDriver
#db.driverclass=com.mysql.jdbc.Driver
db.minpoolsize=1
db.maxpoolsize=5
db.initialpoolsize=2
db.maxidletime=120
db.maxstatements=20
db.idleconnectiontestperiod=60
db.acquireretryattempts=30
db.acquireincrement=3
db.breakafteracquirefailure=false
db.maxstatementsperconnection=20
db.numhelperthreads=3
db.testconnectiononcheckout=false
db.acquireretrydelay=1000
db.autocommitonclose=false
db.checkouttimeout=30000
db.description=A pooled c3p0 DataSource
db.debugunreturnedconnectionstacktraces=false
dbType=oracle
dialect=OracleDialect
#dbType=mysql
#dialect=MySQLDialect
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/applicationcontext-datasource.xml
</param-value>
</context-param>
applicationcontext-datasource.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"
default-lazy-init="true">
<bean
class="com.XXX.dhm.XXX.common.util.XXXPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>datasource.properties</value>
</list>
</property>
</bean>
<!--
<jee:jndi-lookup id="dataSource" jndi-name="java:portalMS" /> -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method="close">
<property name="driverClass">
<value>${db.driverclass}</value>
</property>
<property name="jdbcUrl">
<value>${db.jdbcurl}</value>
</property>
<property name="user">
<value>${db.user}</value>
</property>
<property name="password">
<value>${db.password}</value>
</property>
<property name="minPoolSize">
<value>${db.minpoolsize}</value>
</property>
<property name="maxPoolSize">
<value>${db.maxpoolsize}</value>
</property>
<property name="initialPoolSize">
<value>${db.initialpoolsize}</value>
</property>
<property name="maxIdleTime">
<value>${db.maxidletime}</value>
</property>
<property name="acquireIncrement">
<value>${db.acquireincrement}</value>
</property>
<property name="maxStatements">
<value>${db.maxstatements}</value>
</property>
<property name="idleConnectionTestPeriod">
<value>${db.idleconnectiontestperiod}</value>
</property>
<property name="acquireRetryAttempts">
<value>${db.acquireretryattempts}</value>
</property>
<property name="breakAfterAcquireFailure">
<value>${db.breakafteracquirefailure}</value>
</property>
<property name="testConnectionOnCheckout">
<value>${db.testconnectiononcheckout}</value>
</property>
<property name="numHelperThreads">
<value>${db.numhelperthreads}</value>
</property>
<property name="maxStatementsPerConnection">
<value>${db.maxstatementsperconnection}</value>
</property>
<property name="debugUnreturnedConnectionStackTraces">
<value>${db.debugunreturnedconnectionstacktraces}</value>
</property>
<property name="description">
<value>${db.description}</value>
</property>
<property name="checkoutTimeout">
<value>${db.checkouttimeout}</value>
</property>
<property name="autoCommitOnClose">
<value>${db.autocommitonclose}</value>
</property>
<property name="acquireRetryDelay">
<value>${db.acquireretrydelay}</value>
</property>
</bean>
<bean id="sqlMapClient" class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
<property name="configLocation">
<value>
classpath:ibatis/${dbType}/sqlMapConfig.xml
</value>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dialect" class="com.coship.dhm.portalMS.base.dialect.${dialect}">
<property name="limit" value="true" />
</bean>
<bean id="sqlExecutor" class="com.coship.dhm.portalMS.base.executor.LimitSqlExecutor"
scope="prototype">
<property name="dialect" ref="dialect" />
<property name="enableLimit" value="true"></property>
</bean>
<bean id="baseDao" abstract="true"
class="com.coship.dhm.portalMS.base.dao.ibatis.IbatisDAO" init-method="initialize">
<property name="sqlMapClient">
<ref bean="sqlMapClient" />
</property>
<property name="sqlExecutor">
<ref bean="sqlExecutor" />
</property>
</bean>
<bean id="iBatisTransactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<tx:advice id="txAdvice" transaction-manager="iBatisTransactionManager">
<tx:attributes>
<!-- <tx:method name="del*" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method>
<tx:method name="save*" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method>
<tx:method name="add*" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method>
<tx:method name="update*" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method>
<tx:method name="batch*" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method>
<tx:method name="execute" propagation="REQUIRED"
rollback-for="com.coship.dhm.portalMS.exception.portalMSException"></tx:method> -->
<tx:method name="*" propagation="REQUIRED" rollback-for="Exception"></tx:method>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="tesConntpoint"
expression="execution(* com.coship.dhm.portalMS.*.dao..*.*(..)) or execution(* com.XXX.dhm.portalMS.*.service..*.*(..)) " />
<aop:pointcut id="iepgPoint"
expression="execution(* com.coship.dhm.portalMS.*.service..*.*(..)) or execution(* com.XXX.createPortal.*.service..*.*(..)) or execution(* com.coship.dhm.common.uif.service.impl.MessageSyncServiceImpl.*(..)) " />
<aop:pointcut id="logpoint"
expression="execution(* com.coship.dhm.portalMS.*.service..*.*(..))
or execution(* com.coship.dhm.portalMS.*.dao..*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="iepgPoint" />
<aop:aspect id="logging" ref="logAspect">
<aop:around pointcut-ref="logpoint" method="invoke" />
</aop:aspect>
<aop:aspect id="testConn" ref="testConnAspect">
<aop:before method="before" pointcut-ref="tesConntpoint" />
</aop:aspect>
</aop:config>
<bean id="testConnAspect" class="com.coship.dhm.portalMS.common.aop.JdbcTestAspect" />
<bean id="logAspect" class="com.coship.dhm.portalMS.common.aop.LogAspect" />
</beans>