配置druid数据库连接池需要哪些jar包

如题所述

第1个回答  推荐于2016-05-08
<dependencies>
    <dependency>
        <groupId>javax.transaction</groupId>
        <artifactId>jta</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>${spring.version}</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-ibatis</artifactId>
        <version>2.0.8</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.3.0</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis-spring</artifactId>
        <version>1.2.2</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.6.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.6.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.35</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>net.sourceforge.jtds</groupId>
        <artifactId>jtds</artifactId>
        <version>1.3.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.1-901-1.jdbc4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.oracle</groupId>
        <artifactId>ojdbc6</artifactId>
        <version>11.2.0.3</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.quartz-scheduler</groupId>
        <artifactId>quartz</artifactId>
        <version>2.2.1</version>
        <scope>provided</scope>
        <optional>true</optional>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.derby</groupId>
        <artifactId>derby</artifactId>
        <version>10.9.1.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>commons-dbcp</groupId>
        <artifactId>commons-dbcp</artifactId>
        <version>1.4</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp</artifactId>
        <version>0.7.1.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jolbox</groupId>
        <artifactId>bonecp-spring</artifactId>
        <version>0.7.1.RELEASE</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>proxool</groupId>
        <artifactId>proxool</artifactId>
        <version>0.9.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>proxool</groupId>
        <artifactId>proxool-cglib</artifactId>
        <version>0.9.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>c3p0</groupId>
        <artifactId>c3p0</artifactId>
        <version>0.9.1.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jdbc</artifactId>
        <version>8.0.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.ibatis</groupId>
        <artifactId>ibatis-sqlmap</artifactId>
        <version>2.3.4.726</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <version>1.3.170</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>4.1.9.Final</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.nutz</groupId>
        <artifactId>nutz</artifactId>
        <version>1.b.52</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.taobao.tbdatasource</groupId>
        <artifactId>tbdatasource</artifactId>
        <version>2.0.2</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <groupId>jboss</groupId>
                <artifactId>jboss-j2ee</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.javasimon</groupId>
        <artifactId>javasimon-spring</artifactId>
        <version>3.3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.javasimon</groupId>
        <artifactId>javasimon-jdbc4</artifactId>
        <version>3.3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.javasimon</groupId>
        <artifactId>javasimon-javaee</artifactId>
        <version>3.3.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>14.0.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.aliyun.odps</groupId>
        <artifactId>odps-sdk-udf</artifactId>
        <version>0.17.3</version>
        <scope>provided</scope>
        <optional>true</optional>
        <exclusions>
            <exclusion>
                <groupId>javax.validation</groupId>
                <artifactId>validation-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies>

从官方pom文件来看druid依赖上面这些jar包,建议直接使用maven

<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>druid</artifactId>
    <version>${druid-version}</version>
</dependency>

可以自动引入依赖jar包,就可以免去下载依赖jar包的麻烦了

本回答被提问者采纳

为什么说druid是"最好的数据库连接池"?体现在哪些方面
单独使用dbcp需要3个包:common-dbcp.jar,common-pool.jar,common-collections.jar由于建立数据库连接是一个非常耗时耗资源的行为,所以通过连接池预先同数据库建立一些连接,放在内存中,应用程序需要建立数据库连接时直接到连接池中申请一个就行,用完后再放回去。dbcp没有自动的去回收空闲连接的功能。2、...

druid连接池中的连接数与预期不一致的一次分析
配置keepalive为true时,idleMillis大于keepAliveBetweenTimeMillis,当前连接会被维护到保活集合中,以确保连接可用,避免意外回收。分析总结 结合项目现有的配置和依赖的jar包版本,连接池中的连接数不总是与初始连接数或最小空闲连接数保持一致。在使用1.0.22、1.1.10版本的应用中,如果SQL请求不是非常...

Druid 参数配置详解
Druid是连接池的佼佼者,其使用方法相对简单。不再直接通过驱动创建连接,而是通过DruidDataSource对象来获取。以Spring Boot为例,首先需要在项目中添加Druid的依赖,并配置连接池。这包括设定最大连接数等性能参数。在安全性方面,Druid支持密码加密,以保护明文密码。在配置文件中,通过设置config.decrypt=tr...

创建maven工程之后,pom文件中需要引入哪些jar包?
1、引入框架相关的依赖,比如spring、mybatis等 2、引入数据库相关依赖,比如druid(连接池)、mysql-connector-java(mysql驱动)等 3、引入所需中间件依赖,比如dubbo、redis、kafka等 4、引入工具包依赖,比如fastjson(JSON)、apache poi(Excel解析)等 5、微服务架构按需引入其他模块的依赖,比如 myap...

druid连接池配置介绍
通过connectProperties属性开启mergeSql功能收集慢SQL记录,慢SQL阈值设定为5000毫秒。配置监控统计拦截的filters,包括stat、log4j、wall、aia.cn.posa.config等。配置登录管理,使监控界面可访问,允许使用用户名admin和密码admin登录。这将便于实时监控和管理数据库连接池,确保系统性能和安全性。

Spring Boot 3 集成 Druid 连接池详解
在Spring Boot 3项目中,集成高效的数据库连接池是至关重要的,而Druid以其丰富的监控和管理特性备受青睐。本文将指导你如何在Spring Boot 3中配置数据源,采用Druid连接池以优化数据库管理。首先,Spring Boot 3自动配置功能使得项目引入spring-boot-starter-jdbc依赖和MySQL驱动变得简单。只需在pom.xml中...

Spring Boot (三) 整合 Druid 连接池
1、在pom.xml文件中添加Druid依赖。确保与项目需求兼容。2、在application.yml配置文件中设置Druid连接池参数,包括但不限于数据源URL、用户名、密码等。3、创建Druid核心配置类,自定义连接池属性,如最大连接数、验证间隔等。4、访问127.0.0.1:8080\/druid\/页面,即可查看监控信息。直观的数据展示帮助...

Druid链接池的配置和使用
1.8. 编解码格式(useUnicode 和 characterEncoding):根据数据库情况配置,建议设置为useUnicode=true&characterEncoding=UTF-8。2. 连接池配置包括初始值、最大值、最小值。2.1. 连接池初始化时,会自动创建initialSize个连接(例如5个),这些连接会持续存在,直到客户端并发量超过初始值。2.2. 当...

阿里巴巴主流数据库连接池Druid入门
为了深入学习Druid数据库连接池,首先需要创建properties文件来配置连接池参数,如数据库地址、用户名、密码等。接着,创建连接池实例,并通过连接池获取连接对象,以进行SQL操作。连接池在获取连接后,还需进行测试以确保其功能正常,包括连接成功创建等。此外,学习过程中需关注Druid数据库连接池的常见配置...

Druid数据连接池Druid
Druid是一个全面的数据库连接管理解决方案,它不仅是一个连接池,还包括ProxyDriver、内置JDBC组件库和SQL解析器。Druid兼容多种数据库,如Oracle、MySQL、Derby、PostgreSQL、SQL Server和H2等,对Oracle和MySQL进行了专门优化,如内存占用优化和ping检测。Druid的扩展性突出,它在DruidDataSource和ProxyDriver上...

相似回答