日期:2014-05-16  浏览次数:20493 次

Spring+JDBCTemplate事务
<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName"><value>oracle.jdbc.OracleDriver</value></property>
        <property name="url"><value>jdbc:oracle:thin:@192.168.100.64:1521:spdx</value></property>
        <property name="username"><value>key</value></property>
        <property name="password"><value>key</value></property>
    </bean>
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource"><ref bean="dataSource" /></property>
    </bean>
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="query*" read-only="true" />
<tx:method name="update*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<aop:config>
<aop:pointcut id="oper1" expression="execution(* com.spdx.app.dao.AccountDAO.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="oper1" />
</aop:config>