Directly on the code
<?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:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"
xmlns:p= "http://www.springframework.org/schema/p"
xsi:schemalocation= "Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/ Spring-aop-2.0.xsd Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-3.1.xsd Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/ Spring-tx.xsd "
xmlns:tx= "Http://www.springframework.org/schema/tx" >
<!--c3p0 Data Source Configuration--
<bean id= "DataSource" class= "Com.mchange.v2.c3p0.ComboPooledDataSource"
destroy-method= "Close" >
<!--Specify the drive to connect to the database
<property name= "Driverclass" value= "Com.mysql.jdbc.Driver"/>
<!--Specify the URL of the connection database--
<property name= "Jdbcurl" value= "jdbc:mysql://localhost:3306/goods?useunicode=true&characterencoding= Utf-8 "/>
<!--Specify the user name to connect to the database--
<property name= "User" value= "root"/>
<!--specify a password to connect to the database--
<property name= "password" value= ""/>
<!--Specify the maximum number of connections to connect to a database connection pool--
<property name= "maxpoolsize" value= "/>"
<!--Specify the minimum number of connections to connect to the database connection pool--
<property name= "Minpoolsize" value= "1"/>
<!--Specify the number of initialization connections to connect to the database connection pool-
<property name= "Initialpoolsize" value= "1"/>
<!--Specify the maximum idle time for connections that connect to a database connection pool-
<property name= "maxidletime" value= "/>"
</bean>
<!--Transaction Propagation Properties Configuration --
<tx:advice id= "Test"Transaction-manager=" > "TransactionManager"
<tx:attributes>
<tx:method name= "save*" propagation= "REQUIRED"/>
<tx:method name= "del*" propagation= "REQUIRED"/>
<tx:method name= "update*" propagation= "REQUIRED"/>
<tx:method name= "add*" propagation= "REQUIRED"/>
<tx:method name= "find*" propagation= "REQUIRED"/>
<tx:method name= "get*" propagation= "REQUIRED"/>
<tx:method name= "apply*" propagation= "REQUIRED"/>
</tx:attributes>
</tx:advice>
<!--Configure the class that participates in the transaction--
<aop:config>
<aop:pointcut id= "Servicemethod"Expression=" Execution (* org.service.*.* (..)) "/>
<aop:advisor pointcut-ref= "Servicemethod"
Advice-ref= "Test"/>
</aop:config>
C3P0 data source configuration and transaction configuration in the spring configuration file (with MySQL)