spring c3p0 配置

 
spring c3p0 配置
 
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beansxmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:aop="http://www.springframework.org/schema/aop"
  5. xmlns:tx="http://www.springframework.org/schema/tx"
  6. xsi:schemaLocation="http://www.springframework.org/schema/beans
  7. http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  8. http://www.springframework.org/schema/tx
  9. http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
  10. http://www.springframework.org/schema/aop
  11. http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"
  12. default-destroy-method="close"
  13. >
  14. <importresource="spring_eqms.xml"/>
  15. <beanid="dataSource"
  16. class="com.mchange.v2.c3p0.ComboPooledDataSource"
  17. destroy-method="close">
  18. <propertyname="driverClass"
  19. value="com.mysql.jdbc.Driver"/>
  20. <propertyname="jdbcUrl"value="jdbc:mysql://xxx:3306/tzerp_db?useUnicode=true&characterEncoding=UTF-8"/>
  21. <propertyname="user"value="root"/>
  22. <propertyname="password"value="root"/>
  23. <!--当连接池中的连接用完时,C3P0一次性创建新连接的数目-->
  24. <propertyname="acquireIncrement"value="10"/>
  25. <!-- 定义在从数据库获取新连接失败后重复尝试获取的次数,默认为30-->
  26. <propertyname="acquireRetryAttempts"value="100"/>
  27. <!-- 两次连接中间隔时间,单位毫秒,默认为1000 -->
  28. <propertyname="acquireRetryDelay"value="1000"/>
  29. <!-- 连接关闭时默认将所有未提交的操作回滚。默认为false -->
  30. <propertyname="autoCommitOnClose"value="false"/>
  31. <!-- 获取连接失败将会引起所有等待获取连接的线程抛出异常。但是数据源仍有效保留,并在下次调
  32. 19.用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认为 false; -->
  33. <propertyname="breakAfterAcquireFailure"value="false"/>
  34. <!--
  35. 22.当连接池用完时客户端调用getConnection()后等待获取新连接的时间,超时后将抛出SQLException,如设为0则无限期等待。单位毫秒,默认为0;
  36. 23.-->
  37. <propertyname="checkoutTimeout"value="0"/>
  38. <!-- 始化时创建的连接数,应在minPoolSize与maxPoolSize之间取值。默认为3;-->
  39. <!-- 最大空闲时间,超过空闲时间的连接将被丢弃。为0或负数则永不丢弃。默认为0; -->
  40. <propertyname="maxIdleTime"value="10000"/>
  41. <!-- 接池中保留的最大连接数。默认为15-->
  42. <propertyname="minPoolSize"><value>10</value></property>
  43. <propertyname="initialPoolSize"value="20"/>
  44. <propertyname="maxPoolSize"value="50"/>
  45. <!-- JDBC的标准参数,用以控制数据源内加载的PreparedStatement数量。但由于预缓存的Statement属
  46. 32.于单个Connection而不是整个连接池。所以设置这个参数需要考虑到多方面的因素,如果maxStatements与
  47. 33.maxStatementsPerConnection均为0,则缓存被关闭。默认为0; -->
  48. <propertyname="maxStatements"value="0"/>
  49. <!-- 连接池内单个连接所拥有的最大缓存Statement数。默认为0; -->
  50. <propertyname="maxStatementsPerConnection"value="0"/>
  51. <!--C3P0是异步操作的,缓慢的JDBC操作通过帮助进程完成。扩展这些操作可以有效的提升性能,通过多线程实现多个操作同时被执行。默认为3;
  52. 38.-->
  53. <propertyname="numHelperThreads"value="3"/>
  54. <!-- 用户修改系统配置参数执行前最多等待的秒数。默认为300; -->
  55. <propertyname="propertyCycle"value="600"/>
  56. </bean>
  57. <beanid="sessionFactory"
  58. class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
  59. <propertyname="dataSource">
  60. <refbean="dataSource"/>
  61. </property>
  62. <propertyname="hibernateProperties">
  63. <props>
  64. <propkey="hibernate.dialect">
  65. org.hibernate.dialect.MySQLDialect
  66. </prop>
  67. <propkey="hibernate.show_sql">
  68. true
  69. </prop>
  70. </props>
  71. </property>
  72. <propertyname="mappingResources">
  73. <list>
  74. <value>entitys/Ryb.hbm.xml</value>
  75. <value>entitys/Dingdanmx.hbm.xml</value>
  76. <value>entitys/Cpgxclb.hbm.xml</value>
  77. <value>entitys/Caigoudanmx.hbm.xml</value>
  78. <value>entitys/Gxb.hbm.xml</value>
  79. <value>entitys/Gxwfmxb.hbm.xml</value>
  80. <value>entitys/Gxwfzb.hbm.xml</value>
  81. <value>entitys/Caigoudan.hbm.xml</value>
  82. <value>entitys/UserQxb.hbm.xml</value>
  83. <value>entitys/Gys.hbm.xml</value>
  84. <value>entitys/Lzsjs.hbm.xml</value>
  85. <value>entitys/Wlgs.hbm.xml</value>
  86. <value>entitys/Zdbhb.hbm.xml</value>
  87. <value>entitys/Cyclb.hbm.xml</value>
  88. <value>entitys/Hjb.hbm.xml</value>
  89. <value>entitys/Toexcel.hbm.xml</value>
  90. <value>entitys/UserGlb.hbm.xml</value>
  91. <value>entitys/User.hbm.xml</value>
  92. <value>entitys/Dingdan.hbm.xml</value>
  93. <value>entitys/Gsjsb.hbm.xml</value>
  94. <value>entitys/Qxb.hbm.xml</value>
  95. <value>entitys/Glb.hbm.xml</value>
  96. <value>entitys/Cpclxxzb.hbm.xml</value>
  97. <value>entitys/Cpgxgys.hbm.xml</value>
  98. <value>entitys/Jgll.hbm.xml</value>
  99. <value>entitys/Xzfldset.hbm.xml</value>
  100. <value>entitys/Cpgxb.hbm.xml</value>
  101. <value>entitys/Cpclxxmxb.hbm.xml</value>
  102. <value>entitys/Rjzc.hbm.xml</value>
  103. <value>entitys/Bmb.hbm.xml</value>
  104. <value>entitys/Syb.hbm.xml</value>
  105. <value>entitys/Kehu.hbm.xml</value>
  106. </list>
  107. </property>
  108. </bean>
  109. <beanid="myHibTransactionManager"
  110. class="org.springframework.orm.hibernate3.HibernateTransactionManager">
  111. <propertyname="sessionFactory"ref="sessionFactory"/>
  112. </bean>
  113. <tx:adviceid="txAdvice"
  114. transaction-manager="myHibTransactionManager">
  115. <tx:attributes>
  116. <tx:methodname="add*"propagation="REQUIRED"/>
  117. <tx:methodname="del*"propagation="REQUIRED"/>
  118. <tx:methodname="update*"propagation="REQUIRED"/>
  119. <tx:methodname="reg*"propagation="REQUIRED"/>
  120. <tx:methodname="save*"propagation="REQUIRED"/>
  121. <tx:methodname="get*"propagation="SUPPORTS"read-only="true"/>
  122. <tx:methodname="find*"propagation="SUPPORTS"read-only="true"/>
  123. <tx:methodname="login*"propagation="SUPPORTS"read-only="true"/>
  124. </tx:attributes>
  125. </tx:advice>
  126. <aop:config>
  127. <aop:pointcutid="bizMethods"
  128. expression="execution(* services.*.*(..))"/>
  129. <aop:advisoradvice-ref="txAdvice"pointcut-ref="bizMethods"/>
  130. </aop:config>
  131. <beanid="baseDao"class="daos.BaseDao">
  132. <propertyname="sessionFactory">
  133. <refbean="sessionFactory"/>
  134. </property>
  135. </bean>
  136. <beanid="eqmsService"class="services.EqmsServiceImpl"parent="baseDao"></bean>
  137. </beans>
 
原文地址:https://www.cnblogs.com/signheart/p/6609636.html