前言:
如今我们对“mysql连接配置参数”可能比较看重,朋友们都需要学习一些“mysql连接配置参数”的相关知识。那么小编同时在网摘上汇集了一些关于“mysql连接配置参数””的相关文章,希望兄弟们能喜欢,朋友们一起来了解一下吧!##========spring+mysql+druid数据库连接池配置参数详解====================================# 数据库配置db.host = 127.0.0.1db.port = 3306db.database = test-dbdb.username = test-userdb.password = jhkdhjkhfkjhiiuei5646d5f65adf454a4654g56d46a6f5dd4fadgdggffdFFFFdafgee646d65a645ddk/mQ==publicKey = iKKDJFKkkdkfkllkKKDFKLDFLFOHGIHGIHGIHGOO67568D7F6D7FFD76D76D7657KDJFDJD5555D857ADFFJOADIOIOFIOPIFPUFUIPOPADOIOFIOUGPOAIPIODPIQ==spring.datasource.type = com.alibaba.druid.pool.DruidDataSourcespring.datasource.driver-class-name = com.mysql.jdbc.Driverspring.datasource.url = jdbc:mysql://${db.host}:${db.port}/${db.database}?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false&autoReconnect=true&failOverReadOnly=falsespring.datasource.username = ${db.username}spring.datasource.password = ${db.password}# druid配置# 1. 数据源配置spring.datasource.druid.type = ${spring.datasource.type}spring.datasource.druid.driver-class-name = ${spring.datasource.driver-class-name}spring.datasource.druid.url = ${spring.datasource.url}spring.datasource.druid.username = ${spring.datasource.username}spring.datasource.druid.password = ${spring.datasource.password}# 2. 连接池配置# 初始化连接池大小,默认0spring.datasource.druid.initial-size = 5# 最大连接池大小,默认8spring.datasource.druid.max-active = 10# 最小连接池大小,默认0spring.datasource.druid.min-idle = 5# 申请连接最大等待时间(ms)spring.datasource.druid.max-wait = 10000#***************下面标星的三个参数很重要很重要很重要,重要的事情说三遍,不然会可能导致新请求无连接可用,因为废弃的连接没回收,而连接池又满了*************#是否回收废弃连接*****************spring.datasource.druid.remove-abandoned = true#超时时间(以秒数为单位),连接池里废弃连接超过180秒就回收****************spring.datasource.druid.remove-abandoned-timeout = 180#是否在自动回收超时连接的时候打印连接的超时错误*****************spring.datasource.druid.log-abandoned = true# 用于检测连接是否有效的SQLspring.datasource.druid.validation-query = select 'x' FROM DUAL# 申请连接时检测是否有效spring.datasource.druid.test-on-borrow = false# 归还连接时检测是否有效spring.datasource.druid.test-on-return = false# 申请连接时空闲时间大于timeBetweenEvictionRunsMillis,则检测是否有效spring.datasource.druid.test-while-idle = true# 空闲时间大于此值则关闭物理连接,默认1min(60000)spring.datasource.druid.time-between-eviction-runs-millis = 60000# 连接最小存活时间,默认30min(1800000)spring.datasource.druid.min-evictable-idle-time-millis = 1200000# 是否保持连接spring.datasource.druid.keep-alive = true# keepalive检测时间间隔,默认2min(120000)spring.datasource.druid.keep-alive-between-time-millis = 120000# 3. 过滤器配置spring.datasource.druid.filters = config,stat,wall# 配置过滤器spring.datasource.druid.filter.config.enabled = truespring.datasource.druid.connection-properties = config.decrypt=true;config.decrypt.key=${publickey}# 防SQL注入过滤器spring.datasource.druid.filter.wall.enabled = truespring.datasource.druid.filter.wall.config.multi-statement-allow = truespring.datasource.druid.filter.wall.config.condition-double-const-allow = true
版权声明:
本站文章均来自互联网搜集,如有侵犯您的权益,请联系我们删除,谢谢。