In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the knowledge about "how to join druid connection pool in Springboot". In the actual case operation process, many people will encounter such difficulties. Next, let Xiaobian lead you to learn how to deal with these situations! I hope you can read carefully and learn something!
1. Introduction to DROID Connection Pool
Druid is a database connection pool developed by Alibaba and claimed to be born for monitoring. Druid is the best database connection pool at present.
In terms of function, performance and scalability, it surpasses other database connection pools. At the same time, log monitoring is added.
DB pool connections and SQL execution can be well monitored.
2. Parameters of DROID
jdbcUrl URL to connect to database: mysql : jdbc:mysql://localhost:3306/test
username The username of the database
password password database password
driverClassName Driver ClassName. Automatic identification according to url, this item can be matched or not, if druid is not configured, dbType will be automatically identified according to url
driverClassName configuration:
initialSize The number of physical connections established at initialization. Initialization occurs when the display calls the init method, or the first getConnection
maxActive Maximum number of connection pools
maxIdle is no longer in use, configured to no effect
minIdle Minimum number of connection pools
maxWait Gets the maximum waiting time for a connection in milliseconds
3. configuration dependent com.alibaba druid-spring-boot-starter 1.2.8 log4j log4j 1.2.17 4. add files
Add to application.yml or application.properties file (both files are essentially the same, yml file is recommended)
#database connection pool druid configuration spring: #data source: #1.JDBC type: com.alibaba.druid.pool.DruidDataSource #Driving class driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/t263? useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false username: root password: 123 druid: #2. Connection Pool Configuration #Initialize the number of connections in the connection pool, minimum, maximum initial-size: 5 min-idle: 5 max-active: 20 #Configure the timeout for getting connections max-wait: 60000 #Configure how often to detect idle connections that need to be closed, in milliseconds time-between-eviction-runs-millis: 60000 #Configure the minimum survival time of a connection in the pool, in milliseconds min-evictable-idle-time-millis: 30000 validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: true test-on-return: false #Whether to cache preparedStatement, i.e. PSCache official recommendation MySQL is recommended to close Personal advice If you want to use SQL Firewall advice open pool-prepared-statements: true max-pool-prepared-statement-per-connection-size: 20 #Configure monitoring statistics to intercept filters, remove the monitoring interface sql cannot count,'wall' is used for firewall filter: stat: merge-sql: true slow-sql-millis: 5000 #3. Basic Monitoring Configuration web-stat-filter: enabled: true url-pattern: /* #Set which URLs are not counted exclusions: "*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*" session-stat-enable: true session-stat-max-count: 100 stat-view-servlet: enabled: true url-pattern: /druid/* reset-enable: true #Set login and password for monitoring page login-username: admin login-password: admin allow: 127.0.0.1 "Springboot how to join the druid connection pool" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the website. Xiaobian will output more high-quality practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.