<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:context="http://www.springframework.org/schema/context"
 xmlns:tx="http://www.springframework.org/schema/tx"
 xmlns="http://www.springframework.org/schema/beans"
 xsi:schemaLocation="http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-4.2.xsd
 http://www.springframework.org/schema/context
 http://www.springframework.org/schema/context/spring-context-4.2.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
 http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-4.2.xsd ">
     
    <!--指定读取配置文件 -->
       <context:property-placeholder location="classpath:db.properties"/>
    <!-- 事物核心管理器  依赖连接池 -->
        <bean name="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
               <property name="dataSource" ref="dataSource"></property>
        </bean>
    <!-- 事物模板对象  -->
        <bean name="transactionTemplat" class="org.springframework.transaction.support.TransactionTemplate">
              <property name="transactionManager" ref="transactionManager"></property>
         </bean>
   <!-- p配置事物通知  -->
         <tx:advice id="txAdvice" transaction-manager="transactionManager">
            <tx:attributes>
                <tx:method name="transfer" isolation="REPEATABLE_READ" propagation="REQUIRED" read-only="false"/>
            </tx:attributes>
         </tx:advice>
       <!-- 配置织入  -->
         <aop:config>
     <!-- 切点表达式 -->
             <aop:pointcut expression="execution(* cn.yanglin.service.*ServiceImp.*(..))" id="txPc"/>
     <!-- 配通知给 切点-->
             <aop:advisor advice-ref="txAdvice" pointcut-ref="txPc"/>
         </aop:config>
  <!--1 将连接池放进spring容器 -->
   <bean name="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
       <property name="jdbcUrl" value="${jdbc.jdbcUrl}"></property>
       <property name="driverClass" value="${jdbc.driverClass}"></property>
       <property name="user" value="${jdbc.user}"></property>
       <property name="password" value="${jdbc.password}"></property>
   </bean>
   <!-- 2 将jdbc模板放进连接池 -->
    <bean name="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
         <property name="dataSource" ref="dataSource"></property>
   </bean>
   <!-- 3将AccountDaoIml放进连接池 -->
   <bean name="accountDaoImp" class="cn.yanglin.dao.AccountDaoImp">
           <property name="dataSource" ref="dataSource"></property>
   </bean>
   <!-- 4将放进连接池 -->
   <bean name="accountService" class="cn.yanglin.service.AccountServiceImp">
           <property name="ad" ref="accountDaoImp"></property>
   </bean>
</beans>

AOP 事物连接,记忆连接数据库,连接池的更多相关文章

  1. Django ORM 以连接池方式连接底层连接数据库方法

    django原生支持是不支持 以连接池方式连接数据库的 概述 在使用 Django 进行 Web 开发时, 我们避免不了与数据库打交道. 当并发量低的时候, 不会有任何问题. 但一旦并发量达到一定数量 ...

  2. MySQL之长连接、短连接、连接池

    当数据库服务器和客户端位于不同的主机时,就需要建立网络连接来进行通信.客户端必须使用数据库连接来发送命令和接收应答.数据.通过提供给客户端数据库的驱动指定连接字符串后,客户端就可以和数据库建立连接了. ...

  3. Http持久连接与HttpClient连接池

    一.背景 HTTP协议是无状态的协议,即每一次请求都是互相独立的.因此它的最初实现是,每一个http请求都会打开一个tcp socket连接,当交互完毕后会关闭这个连接. HTTP协议是全双工的协议, ...

  4. Http 持久连接与 HttpClient 连接池

    一.背景 HTTP协议是无状态的协议,即每一次请求都是互相独立的.因此它的最初实现是,每一个http请求都会打开一个tcp socket连接,当交互完毕后会关闭这个连接. HTTP协议是全双工的协议, ...

  5. OpenResty 高阶实战之————Redis授权登录使用短连接(5000)和长连接(500W) 使用连接池AB压力测试结果

    一.短连接开始测试 ab -n 5000 -c 100 -k 127.0.0.1/test_redis_short #demo1 Concurrency Level: Time taken for t ...

  6. 通常每个套接字地址(协议/网络地址/端口)只允许使用一次。 数据库连接不释放测试 连接池 释放连接 关闭连接 有关 redis-py 连接池会导致服务器产生大量 CLOSE_WAIT 的再讨论以及一个解决方案

    import pymysqlfrom redis import Redisimport time h, pt, u, p, db = '192.168.2.210', 3306, 'root', 'n ...

  7. django更换ORM连接处理(连接池)转

    1 概述 在使用 Django 进行 Web 开发时, 我们避免不了与数据库打交道. 当并发量低的时候, 不会有任何问题. 但一旦并发量达到一定数量, 就会导致 数据库的连接数会被瞬时占满. 这将导致 ...

  8. django 重写 mysql 连接库实现连接池

    django 重写 mysql 连接库实现连接池 问题 django 项目使用 gunicorn + gevent 部署,并设置 CONN_MAX_AGE 会导致 mysql 数据库连接数飙升,在高并 ...

  9. tcp长连接、短连接、连接池的思考

    在基于tcp的 rcp实现方式中,有如下几种选择: 1. 长连接:同步和异步方式. 同步方式下客户端所有请求共用同一连接,在获得连接后要对连接加锁,在读写结束后才解锁释放连接,性能低下,基本很少采用, ...

  10. java原生程序redis连接(连接池/长连接和短连接)选择问题

    最近遇到的连接问题我准备从重构的几个程序(redis和mysql)长连接和短连接,以及连接池和单连接等问题用几篇博客来总结下. 这个问题的具体发生在java原生程序和redis的交互中.这个问题对我最 ...

随机推荐

  1. 项目上使用的每月1日自动导出Zabbix性能数据的python脚本

    基于zabbix-manager python2.7 #!/usr/bin/env python # -*- coding: utf-8 -*- # __author__ = "life&q ...

  2. Python 3.x版本中的字符串

  3. dva与create-react-app的结合使用

    dva与我们的create-react-app创建的两款脚手架是我们写react项目的两款优秀框架,之前一种使用create-react-app这款脚手架进行开发.然后这个框架美中不足的是redux方 ...

  4. 2019-7-20-win10-uwp-使用-msbuild-命令行编译-UWP-程序

    title author date CreateTime categories win10 uwp 使用 msbuild 命令行编译 UWP 程序 lindexi 2019-07-20 21:56:2 ...

  5. Oracle基础学习4--Oracle权限传递

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/wang379275614/article/details/32215325 以下将用一个实例来解说: ...

  6. @codeforces - 1205D@ Almost All

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定一个 n 个点的无向树. 请在每条边上写上权值,使得对于每一 ...

  7. shell去掉最后一个字符

    实测过第一种写法,可正常删除 sed 's/.$//' awk '{sub(/.$/,"")}1' awk '{printf $0"\b \n"}' ufile ...

  8. phpStudy本地环境测试,打开网页很慢的解决办法!

    很多人应该都遇到了在使用phpStudy本地环境测试软件时候打开很慢的问题,甚至动辄达到了1000ms以上,开篇直接给出解决办法: 下面给大家介绍phpstudy访问速度慢的解决办法. 1.修改mys ...

  9. zoj 1633 Big String

    Big String Time Limit: 2 Seconds Memory Limit: 65536 KB We will construct an infinitely long string ...

  10. [转]java常用正则表达式

    只能输入数字:"^[0-9]*$".  只能输入n位的数字:"^\d{n}$".  只能输入至少n位的数字:"^\d{n,}$".  只能输 ...