阿里云计算平台DataWorks(https://help.aliyun.com/document_detail/137663.html) 团队出品,为监控而生的数据库连接池
27.97k
stars
8.58k
forks
source link
spring.datasource.druid.connection.connection-holder.data-source.connection-init-sqls[0] 报错 #2490
Open
jinzhaopo opened 6 years ago
项目启动的时候,有时候会报错,有时候不会报错。 springboot M2 druid 1.1.9 配置:
druid datasouce database settings begin
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=xxxxxxx spring.datasource.password=PPIL5SY70a63sBoTriaqCwIpYsQZm4/upeMwkRsBjbGs4BPkUegvZBF8nWB379iM92qAp3kpEYikd4KNExGQhA== spring.datasource.url=jdbc:mysql://sh-cdb-qcptqb08.sql.tencentcdb.com:63310/test?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8
public-key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAMtwxWlHhEreKvHefOi89I5xYa14CUdnLjHUGilSacNh5Y+WEatQMrn/Qxtk5lLKtVCPhiDmbrDlPPCWBpH3MU8CAwEAAQ==
\u4e0b\u9762\u4e3a\u8fde\u63a5\u6c60\u7684\u8865\u5145\u8bbe\u7f6e\uff0c\u5e94\u7528\u5230\u4e0a\u9762\u6240\u6709\u6570\u636e\u6e90\u4e2d
\u521d\u59cb\u5316\u5927\u5c0f\uff0c\u6700\u5c0f\uff0c\u6700\u5927
spring.datasource.druid.initialSize=5 spring.datasource.druid.minIdle=5 spring.datasource.druid.maxActive=20
\u914d\u7f6e\u83b7\u53d6\u8fde\u63a5\u7b49\u5f85\u8d85\u65f6\u7684\u65f6\u95f4
spring.datasource.druid.maxWait=60000
\u914d\u7f6e\u95f4\u9694\u591a\u4e45\u624d\u8fdb\u884c\u4e00\u6b21\u68c0\u6d4b\uff0c\u68c0\u6d4b\u9700\u8981\u5173\u95ed\u7684\u7a7a\u95f2\u8fde\u63a5\uff0c\u5355\u4f4d\u662f\u6beb\u79d2
spring.datasource.druid.timeBetweenEvictionRunsMillis=60000
\u914d\u7f6e\u4e00\u4e2a\u8fde\u63a5\u5728\u6c60\u4e2d\u6700\u5c0f\u751f\u5b58\u7684\u65f6\u95f4\uff0c\u5355\u4f4d\u662f\u6beb\u79d2
spring.datasource.druid.minEvictableIdleTimeMillis=300000 spring.datasource.druid.validationQuery=SELECT 1 FROM DUAL spring.datasource.druid.testWhileIdle=true spring.datasource.druid.testOnBorrow=false spring.datasource.druid.testOnReturn=false
\u6253\u5f00PSCache\uff0c\u5e76\u4e14\u6307\u5b9a\u6bcf\u4e2a\u8fde\u63a5\u4e0aPSCache\u7684\u5927\u5c0f
spring.datasource.druid.poolPreparedStatements=true spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20
\u914d\u7f6e\u76d1\u63a7\u7edf\u8ba1\u62e6\u622a\u7684filters\uff0c\u53bb\u6389\u540e\u76d1\u63a7\u754c\u9762sql\u65e0\u6cd5\u7edf\u8ba1\uff0c'wall'\u7528\u4e8e\u9632\u706b\u5899
spring.datasource.druid.filters=stat,wall,log4j,config
\u901a\u8fc7connectProperties\u5c5e\u6027\u6765\u6253\u5f00mergeSql\u529f\u80fd\uff1b\u6162SQL\u8bb0\u5f55
spring.datasource.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
加密并注入publicKey
spring.datasource.druid.connection-properties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000;config.decrypt=true;config.decrypt.key=${public-key}
spring.datasource.druid.connection-init-sqls=set names utf8mb4 spring.datasource.druid.useGlobalDataSourceStat=true
E2BC3D23-EE3A-48b1-9967-C4562F6A5400.txt