<?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. 易位构词EOJ3451【字符串】【思维题】【模拟】

    http://acm.ecnu.edu.cn/problem/3451/ 官方题解: 我们可以先考虑字符串有序的情况,比如是 aaabcc,我们只要将字符串右移 3 位,变成 bccaaa,就做完了. ...

  2. Xcode 中的Bundle versions string, short 和 Bundle version 区别

    Bundle version is the internal version number of your app. Short version string is the publically vi ...

  3. linux中$@,$*,$0,$$,$?参数的含义

    $# 是传给脚本的参数个数 $ 是脚本本身的名字 $ 是传递给该shell脚本的第一个参数 $ 是传递给该shell脚本的第二个参数 $@ 是传给脚本的所有参数的列表 $* 是以一个单字符串显示所有向 ...

  4. Ubuntu修改root密码,ssh 允许root用户登录

    1,切换为root用户 2,passwd root(or others) 3,输两次密码 4,重启. ssh允许root用户登录: 1,vim /etc/ssh/sshd_config 2,修改Per ...

  5. spring data jpa使用别名--as

    使用jpa进行两表联查时总会有字段名相同,所以需要用别名进行区分: 例子: department表同时包含子级id和父级id: 查询语句为: select d.id,d.name,d.descript ...

  6. 基本数据类型的值传递 和引用数据类型的引用传递 Day06

    ValueTest1.java package com.sxt.valuetest; /* * 基本数据类型的传递:传递的是值得副本 */ public class ValueTest1 { publ ...

  7. 解决uploadify插件不同浏览器下的兼容性问题

    http://www.thinkphp.cn/code/2138.html uploadify在部分浏览器上没法使用,或者各种报错的解决方法.uploadify插件上传图片是很爽的体验. 如果用chr ...

  8. Laravel 的HTTP请求#

    获取请求# 要通过依赖注入的方式来获取当前HTTP请求的实例,你应该在控制器方法中类型提示Illuminate\Http\Request 传入的请求的实例通过 服务容器自动注入: <?php n ...

  9. 同一个C语言工程不同C文件之间的函数互相调用问题

    定义一个function.h文件来声明这些函数: //#ifndef __FUNCTION_H__//#define __FUNCTION_H__   int fun(int,int);   int ...

  10. python selenium 基础框架

    base_page.py # coding=utf-8 import time from selenium.common.exceptions import NoSuchElementExceptio ...