最近项目用c3p0数据连接池有问题,因此换成了druid连接池,它的优点是可以很好的监控DB池连接和SQL的执行情况。在此做个记录便于下次使用。

1、首先导入Spring(网上很多这里我就不列举了)和Druid(druid-1.0.9.jar)的相关jar包

2、在web.xml中搭建Spring和Druid的环境

org.springframework.web.context.ContextLoaderListener

DruidStatView

com.alibaba.druid.support.http.StatViewServlet

DruidStatView

/druid/*

3、在Spring-servlet.xml中配置druid数据连接池

4、编写java文件

@Service

public class JdbcServiceBean {

protected SimpleJdbcTemplate simpleJdbcTemplate;

@Resource(name = "dataSource")

public void setDataSource(DataSource dataSource) {

this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource);

}

}

java spring druid_Spring配置Druid连接池相关推荐

  1. Spring Boot 使用 Druid 连接池详解

    Spring Boot 使用 Druid 连接池详解 Alibaba Druid 是一个 JDBC 组件库,包含数据库连接池.SQL Parser 等组件,被大量业务和技术产品使用或集成,经历过严苛的 ...

  2. spring配置druid连接池和监控数据库访问性能

    Druid连接池及监控在spring配置如下: [html] view plaincopy <bean id="dataSource" class="com.ali ...

  3. Spring Boot下Druid连接池的使用配置分析

    引言: 在Spring Boot下默认提供了若干种可用的连接池,Druid来自于阿里系的一个开源连接池,在连接池之外,还提供了非常优秀的监控功能,这里讲解如何与Spring Boot实现集成. 1.  ...

  4. springboot 2.0.5配置Druid连接池和web监控后台

    配置类: import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.support.http.StatViewSe ...

  5. 2020年的spring boot 使用druid连接池 的druid配 置 文 件 properties 版和yml版

    #配置连接池 spring.datasource.username=root spring.datasource.password=root spring.datasource.driver-clas ...

  6. SpringBoot配置druid连接池

    一.添加pom.xml <dependency><groupId>com.alibaba</groupId><artifactId>druid-spri ...

  7. spring-boot中使用druid连接池

      最近因为项目的要求,需要在spring-boot中配置druid连接池,数据库是Oracle,并且是多数据源的连接池,特地写下我的配置经历.   用的框架是spring-boot,数据库是orac ...

  8. druid连接池 - 长时间阻塞问题排查

    前言 最近参与一个新项目,从老项目拷贝过来的代码,同样用的druid连接池 + PG.但是新项目却经常出现阻塞的情况,有时候甚至可以阻塞半个小时.一时间傻眼了.. 问题排查 问题背景 我们一共有6个开 ...

  9. Spring学习总结(12)——Druid连接池及监控在spring配置

    Druid连接池及监控在 spring 配置如下: <bean  id="dataSource" class="com.alibaba.druid.pool.Dru ...

最新文章

  1. springboot+vue在线音乐网站
  2. Halcon知识: 矩形测量
  3. JAVA中randomfile_java中的RandomAccessFile的用法
  4. android手机微信收藏功能实现,Android模仿微信收藏文件的标签处理功能
  5. 基础系列(1)-- html
  6. C#通过反射动态加载dll,读取module、类、方法、特性,并通过反射+简单工厂+配置文件 实现ioc
  7. MVC @RenderBody、@RenderSection、@RenderPage、@Html.RenderPartial、@Html.RenderAction
  8. Java根据中国姓氏的拼音的首字母进行数组的排序
  9. 基于web的库存管理系统
  10. 中兴B860AV2.1、1.1T、2.1-A-M-T,通刷线刷固件及教程
  11. Java基础入门笔记
  12. 管家婆财贸双全存货核算类型对应会计科目禁止删除
  13. Nebula Graph介绍和SpringBoot环境连接和查询
  14. 计算机课ppt插入图片,PPT中图片的巧妙切换 -电脑资料
  15. display 常用属性
  16. 随机编码生成器MD5加密字符串工具
  17. mpeg1视频解码标准简介
  18. HYGGE 一元函数积分学
  19. mysql设置不用科学记数法,关闭科学记数法MySQL
  20. fragment与activity之间的信息传递的两种方式

热门文章

  1. 前端学习(595):使用network进行详细分析
  2. CSS之calc()使用
  3. Linux Shell中有三种引号的用法
  4. kafka 常用命令汇总
  5. [转载来之雨松:NGUI研究院之为什么打开界面太慢(十三)]
  6. 如何让 C++ 和 C# 一样易用,而且效率更高?
  7. Information_Schema系统表
  8. DecimalFormat很强大
  9. 黑马Java学习笔记之-----集合框架
  10. 街篮混服服务器信息,街篮手游闻鸡起舞服务器火爆开启