<?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. 安装 FastAdmin 时忘记 MySQL 密码怎么办?

    安装 FastAdmin 时忘记 MySQL 密码怎么办? 给 MySQL 启动时加上 skip-grant-tables 参数,然后随便使用用户名都可以进入 MySQL. 接着就可以使用 命令改了 ...

  2. 正则表达式问题:如何理解/href\s*=\s*(?:"(?<1>[^"]*)"|(?<1>\S+))/(转载)

    ms-help://MS.VSCC/MS.MSDNVS.2052/jscript7/html/jsjsgrpregexpsyntax.htm 该文虽有解释, 但没有样例,对我这样的初学者来说很难理解 ...

  3. UVA_488:Triangle Wave

    PS:The input begins with a single positive integer on a line by itself indicating the number of the ...

  4. 巨蟒python全栈开发-第11阶段 ansible_project1

    今日大纲: 1.前端页面介绍 2.发布流程 3.需求分析 4.表结构设计 5.前端页面设计 昨日内容回顾: 1.roles - tasks - handlers - files - templates ...

  5. 1<<33这种写法是错的!!!

    1<<33不能这么写,1默认int类型,应该改为(long long)1<<33

  6. @hdu - 6329@ Problem K. Transport Construction

    目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定 n 个点,第 i 个点位于 (xi, yi). 在第 i ...

  7. 修改Mariadb存储路径

    大部分基于此文章操作:http://lddyw.blog.51cto.com/4151746/1684364 找个好久的资料,都打算源码安装了,最后终于更改成功了. 环境:CentOS6.6 64位虚 ...

  8. 洛谷P3366 【模板】最小生成树(kuskal)

    #include<bits/stdc++.h> using namespace std; ; ; struct node{ int cnt,fa; }f[maxn]; inline voi ...

  9. java基础-内存分配

    1.java运行时的数据区:程序计数器.方法区.虚拟机栈.本地方法栈.堆 ①.程序计数器:一块较小的内存空间,可看作当前线程所执行的字节码的行号指示器 ②.java虚拟机栈:与程序计数器一样,也是线程 ...

  10. 异常解决:non-compatible bean definition of same name and class【com.xxx.xxx.XXX】

    昨天同事遇到这样一个问题,意思是spring找到 有相同的实现类名在不同的package目录下. 跟踪他的项目代码并未发现问题.   重新给他的maven项目进行maven install一下. 查看 ...