Druid数据库连接池

阅读更多
Druid首先是一个数据库连接池。Druid是目前最好的数据库连接池,在功能、性能、扩展性方面,都超过其他数据库连接池,包括DBCP、C3P0、BoneCP、Proxool、JBoss DataSource。
Druid已经在阿里巴巴部署了超过600个应用,经过一年多生产环境大规模部署的严苛考验。
同时Druid不仅仅是一个数据库连接池,它包括四个部分:
Druid是一个JDBC组件,它包括三个部分:
基于Filter-Chain模式的插件体系。
DruidDataSource 高效可管理的数据库连接池。
SQLParser
Druid可以做什么?

替换DBCP和C3P0。Druid提供了一个高效、功能强大、可扩展性好的数据库连接池。
可以监控数据库访问性能,Druid内置提供了一个功能强大的StatFilter插件,能够详细统计SQL的执行性能,这对于线上分析数据库访问性能有帮助。
数据库密码加密。直接把数据库密码写在配置文件中,这是不好的行为,容易导致安全问题。DruidDruiver和DruidDataSource都支持PasswordCallback。
SQL执行日志,Druid提供了不同的LogFilter,能够支持Common-Logging、Log4j和JdkLog,你可以按需要选择相应的LogFilter,监控你应用的数据库访问情况。
扩展JDBC,如果你要对JDBC层有编程的需求,可以通过Druid提供的Filter机制,很方便编写JDBC层的扩展插件。
在项目中使用Druid非常简单,只要修改下配置文件就可以了
下载 druid-0.2.20.jar http://download.csdn.net/detail/wind520/5670085

applicationContext.xml 数据源配置
[html] view plaincopy
 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns:aop="http://www.springframework.org/schema/aop" 
        xmlns:tx="http://www.springframework.org/schema/tx" 
        xsi:schemaLocation=" 
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd 
            http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd 
            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> 
 
    Spring公共配置文件  
 
     
     
         
         
         
             
                 
                classpath*:/application.properties 
           
 
       
 
   
 
     
         
         
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
      
     
     
         
 
         
             
                ${jdbc.dialect} 
                true 
                true 
                org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory 
                ${hibernate.ehcache_config_file} 
                true 
                true 
           
 
       
 
         
             
                com.kingmed.jusmartcare.health.entity 
           
 
       
 
 
   
 
     
     
     
         
   
 
     
     
        
 
 
web.xml 加上
[html] view plaincopy
      
  DruidStatView    
  com.alibaba.druid.support.http.StatViewServlet 
  
    
   DruidStatView 
   /druid/* 
  

就可以了.
监控页面

Druid数据库连接池_第1张图片

  • Druid数据库连接池_第2张图片
  • 大小: 104.8 KB
  • 查看图片附件

你可能感兴趣的:(druid,数据库连接池,阿里巴巴,编程)