Table of Contents
- 1. What is Druid?
- 2. Where is source code?
- 3. How to get the source code
- 4. Maven config
- 5. How to use Druid's monitoring feature?
- 6. How to use Druid buit-in monitoring page
- 7. How to configure Web and Spring related monitoring?
- 8. How to configure against SQL injection attacks
- 9. DruidDataSource reference configuration
- 10. I would like to log SQL execution trace, how to config?
- 11. In the case of connection leaks, what to do?
- 12. Solve the problem of excessive memory footprint Oracle PSCache
- 13. Druid and other connection pools comparision?
- 14. What to consider when migrating from other connection pools?
- 15. Druid equivalent of Jboss DataSource ExceptionSorter
- 16. Why does maxIdle property have no effect?
- 17. How to use DruidDataSource in JNDI?
- 18. How to replace DBCP with Druid?
- 19. How to try a snapshot version?
- 20. How to log records for debugging a slow SQL execution?
- 21. How to encrypt the database password?
- 22. How to contribute to Druid development?
- 23. Questions and suggestions are welcome!
- 24. How to integrate the Druid connection pool and monitoring in Spring Boot project?
- 25. How to add custom WallConfig, Filter in the Spring Boot ?
English | 中文
FAQ
1. What is Druid?
Druid is one of the best database connection pools written in JAVA. Druid provides powerful monitoring functionalities and more.
2. Where is source code?
-
released version download:
github downloads : https://github.com/alibaba/druid/downloads
maven central repository: http://central.maven.org/maven2/com/alibaba/druid/
Alibaba open source repository: http://code.alibabatech.com/mvn/releases/com/alibaba/druid/ -
snapshot versions
http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/
3. How to get the source code
Druid is an open source project which is hosted on Github, source code repository: https://github.com/alibaba/druid
4. Maven config
Since 0.1.18, druid has been deployed to the maven central repository. Add the dependency to the pom.xml as below
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>${druid-version}</version>
</dependency>
5. How to use Druid's monitoring feature?
Druid monitoring feature is implemented through filter-chain. To turn it on, config StatFilter, example: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter
6. How to use Druid buit-in monitoring page
The built-in monitoring page is a Servlet. To configure: https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatViewServlet%E9%85%8D%E7%BD%AE
7. How to configure Web and Spring related monitoring?
- Web related monitoring config
https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_%E9%85%8D%E7%BD%AEWebStatFilter - Spring related monitoring config
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 against SQL injection attacks
Druid provides WallFilter, it is based on the SQL semantic analysis to defense SQL injection attacks, reference : https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE-wallfilter
9. DruidDataSource reference configuration
different needs of different business scenarios, you can use our reference configuration, but it is recommended that you carefully read the documentation to understand clearly do custom configuration.
10. I would like to log SQL execution trace, how to config?
Druid provides Log4jFilter/CommonsLogFilter/Slf4jFilter, see here : https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_LogFilter
11. In the case of connection leaks, what to do?
Druid offers a variety of means to monitor connection leaks, see 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. Solve the problem of excessive memory footprint Oracle PSCache
Connect to an Oracle database, other connection pool will exist the problem of excessive memory usage, Druid is the only connection pool to solve this problem. see here : http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6951277
13. Druid and other connection pools comparision?
- A variety of connection pool against : http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6951797
14. What to consider when migrating from other connection pools?
- comparison of various connection pool parameters: http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6947005
- migration from DBCP : http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=6950500
15. Druid equivalent of Jboss DataSource ExceptionSorter
ExceptionSorter is one of the outstanding features of JBoss DataSource, Druid has the same function of ExceptionSorter. However it does not need to be configured manually. see here : http://code.alibabatech.com/wiki/display/Druid/ExceptionSorter
16. Why does maxIdle property have no effect?
the maxIdle property for Druid compatible with DBCP, maxIdle is a confusing concept. the connection pool should only maxPoolSize and minPoolSize,druid retain only maxActive and minIdle, respectively the equivalent maxPoolSize and minPoolSize.
17. How to use DruidDataSource in JNDI?
DruidDataSource support JNDI, see here : http://code.alibabatech.com/wiki/pages/viewpage.action?pageId=2916633
the concrete implementation of the class is this : com.alibaba.druid.pool.DruidDataSourceFactory, you can read the code to deep understanding.
18. How to replace DBCP with Druid?
It is very easy to migrate from DBCP to Druid.
-
- add druid-xxx.jar and druid-wrapper-x.x.x-jar to library
- add druid-xxx.jar and druid-wrapper-x.x.x-jar to library
-
- remove dbcp-xxx.jar and commons-pool.jar form WEB-INF/lib/
- remove dbcp-xxx.jar and commons-pool.jar form WEB-INF/lib/
-
- Optional parameters, such as JVM startup parameters "-Ddruid.filters=stat", dynamic config druid filters
- Optional parameters, such as JVM startup parameters "-Ddruid.filters=stat", dynamic config druid filters
In this usage, making Druid can be used in existing applications such as sonar, sonar is web application written in ruby, write dead DBCP, only through this method to replace.
19. How to try a snapshot version?
see here : http://code.alibabatech.com/mvn/snapshots/com/alibaba/druid/
20. How to log records for debugging a slow SQL execution?
In StatFilter slow SQL execution logging configuration, see here : https://github.com/alibaba/druid/wiki/%E9%85%8D%E7%BD%AE_StatFilter
21. How to encrypt the database password?
DBA does not want to directly write the password in the config file, Druid provide the features that encrypted database password. see here : https://github.com/alibaba/druid/wiki/%E4%BD%BF%E7%94%A8ConfigFilter
22. How to contribute to Druid development?
Druid is an open source project hosted on github.com, you can "pull request". see here : https://github.com/alibaba/druid/wiki/%E5%A6%82%E4%BD%95%E5%8F%82%E4%B8%8E
23. Questions and suggestions are welcome!
(Welcome to join QQ Group: 240619787 for discuss and study Druid)
24. How to integrate the Druid connection pool and monitoring in Spring Boot project?
Usage Druid Spring Boot Starter,Documentation:https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter