Database Connection Pool druid__ database

Source: Internet
Author: User
Tags memory usage sql injection sybase wrapper jboss maven central


database connection Pool Druid

1. What is Druid.
Druid is the best database connection pool in the Java language. Druid can provide powerful monitoring and extension capabilities.

2. Where to download Druid
Download the official version:
Maven Central Warehouse: Http://central.maven.org/maven2/com/alibaba/druid/
Alibaba open Source Download: Http://code.alibabatech.com/mvn/releases/com/alibaba/druid/
Snapshot version download
Http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/

3. How to obtain Druid source code
Driud is an open source project, the source code hosted on the GitHub, the origin of the warehouse address is https://github.com/alibaba/druid. At the same time, each Druid release of the official version and snapshots, the source code will be packaged, you can download from the above address to find the relevant version of the source code.

4. How to configure Maven
After the Druid 0.1.18 version is released to the MAVEN central repository, you only need to add dependency to the project's pom.xml. For example:

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

5. How to open Druid monitoring statistics function Druid Monitoring statistics function is achieved through the filter-chain extension, if you want to turn on the monitoring statistics function, configuration statfilter, specifically look here:

Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter

6. How to use the Druid built-in monitoring page
Built-in monitoring page is a servlet, specific configuration look here:

Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatViewServlet%E9%85%8D%E7%BD%AE

7. Web and Spring Association monitoring in built-in monitoring how to configure.
Web Association Monitoring Configuration
Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter
Spring Association Monitoring Configuration
Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_Druid%E5%92%8CSpring%E5%85%B3%E8%81%94%E7%9B%91%E6%8E %a7%e9%85%8d%e7%bd%ae

8. How to configure defense SQL injection attacks
Druid provides Wallfilter, which is based on SQL Semantic analysis to implement defense against SQL injection attacks. Specific configuration look here: Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter

9. Druid has no reference configuration
Different business scenarios require different requirements, you can use our reference configuration, but it is recommended that you carefully read the relevant documents, to make a custom configuration after understanding. Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_DruidDataSource%E5%8F%82%E8%80%83%E9%85%8D%E7%BD%AE

10. I would like to log records of the SQL executed by JDBC, how to configure
Druid offers Log4jfilter, Commonslogfilter and Slf4jfilter, specific configuration see here https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD% Ae_logfilter

11. My program may have a connection leak, what is the way.

Druid provides a variety of means of monitoring connection leakage, specifically look here: Https://github.com/alibaba/druid/wiki/%E8%BF%9E%E6%8E%A5%E6%B3%84%E6%BC%8F%E7%9B%91%E6%B5%8B

12. The use of Pscache in Druid will have a large memory footprint problem.

Connecting Oracle databases, opening Pscache, and having excessive memory usage in other database connection pools, Druid is the only connection pool to solve this problem. Specifically look here: http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6951277

13. There is no comparison with other database connection pools. Comparison of various database connection pools http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6951797

14. What to look for when migrating from other connection pools. Parameter reference comparison of different connection pools: http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6947005 dbcp migration http:// code.alibabatech.com/wiki/pages/viewpage.action?pageid=6950500

is there any exceptionsorter in druid like the JBoss datasource?

Exceptionsorter is an excellent feature of JBoss DataSource, Druid also has the same function of Exceptionsorter, but not manually configured to automatically identify the effective. Specifically look here: Http://code.alibabatech.com/wiki/display/Druid/ExceptionSorter

Why is maxidle in the druid?

Maxidle is druid to facilitate DBCP user migration, Maxidle is a confusing concept. The connection pool should only have maxpoolsize and Minpoolsize,druid only retained Maxactive and Minidle, respectively, equivalent to Maxpoolsize and minpoolsize.

17. My application is configured with a JNDI data source, can I use Druiddatasource?

Druiddatasource supports JNDI configuration, specifically look here: http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=2916633
The specific implementation of the class is this: Com.alibaba.druid.pool.DruidDataSourceFactory, you can read the code to deepen understanding.

18. My application has been using DBCP, which is written in the code, and how to replace it with Druid.

OK, Druid provides a way to completely smooth the migration dbcp. 1) from http://repo1.maven.org/maven2/com/alibaba/druid/druid-wrapper/download Druid-wrapper-xxx.jar 2) add Druid-xxx.jar 3) Remove Dbcp-xxx.jar 4 from your web-inf/lib/and configure it as needed, such as JVM startup parameters plus-ddruid.filters=stat, dynamically configuring Druid filters

This usage makes it possible to use Druid in some applications that are not developed, such as the deployment of Druid,sonar in Sonar, a Web application developed using JRuby, written dead dbcp, which can only be replaced by this method.

19. I want to try the snapshot version, how to get.

The address to get the snapshot version directly is: Http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/.

20. Some SQL execution is very slow, I want the log to record, how to set.

There is slow SQL execution logging in the Statfilter configuration, see here Https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter

21. What do I want to encrypt my database password?

The operation and the DBA do not want to write the password directly in the configuration file, Druid provides the database secret encryption function. Specifically look here:

Https://github.com/alibaba/druid/wiki/%E4%BD%BF%E7%94%A8ConfigFilter

22. How to participate in the development of Druid

Druid is an Open-source project through GitHub, GitHub features that make it easy for you to get involved. Here is a detailed description

Https://github.com/alibaba/druid/wiki/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E

What is the release cycle of Druid?

Druid is an active project for long-term maintenance. There is a publishing window each month, which is published at most once a month unless there are major bugs and very urgent requirements. If there is not enough demand, the publishing window will not be used.

24. If Druiddatasource failed at init, no longer used, need close yes, if Druiddatasource is no longer in use, you must call close to release the resource. Freed resources include closing the Create and Destory threads.

which databases are supported by Druiddatasource.

In theory, all databases that have JDBC drivers are supported. The actual test has been

Database Support Status
Mysql Support, Mass use
Oracle Support, Mass use
Sql server Support
Postgres Support
Db2 Support
H2 Support
Derby Support
Sqlite Support
Sybase Support

The update row count is incorrect when JDBC ExecuteBatch is under Oracle

Using the ExecuteBatch method of JDBC, if the database is Oracle, the return value is 2, regardless of whether it was successfully updated to data, rather than the number of records that are actually updated by SQL, which is a problem with Oracle JDBC driver, Druid without special treatment.

Druid How to automatically identify Driverclass based on URLs

        Druid identifies driverclass based on the URL prefix, which makes the configuration easier and simpler.


td>
prefix driverclass description information
jdbc:derb Y org.apache.derby.jdbc.EmbeddedDriver
jdbc:mysql com.mysql.jdbc.Driver
jdbc:oracle oracle.jdbc.driver . Oracledriver
jdbc:microsoft COM.MICROSOFT.JDBC.SQLSERVER.S Qlserverdriver
jdbc:sybase:Tds com.sybase.jdbc2.jdbc.SybDr Iver
jdbc:jtds net.sourceforge.jtds.jdbc.Driver
jdbc:ostgresql org.postgresql.Driver
Jdbc:fake com.alibaba.druid.mo

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.