项目数据库连接池准备用Druid,但是网上搜的配置信息都不一样,都比较乱。
最终在官方GitHub文档上找到了各个配置项的说明,整理了一下,留着备忘。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=root
jdbc.validationQuery=SELECT 1
3 底层调用jdbc Statement对象的void setQueryTimeout(int seconds)方法 jdbc.validationQueryTimeout=3
jdbc.poolPreparedStatements=false
jdbc.maxPoolPreparedStatementPerConnectionSize=-1
jdbc.initialSize=3
jdbc.maxActive=10
jdbc.minIdle=0
jdbc.maxWait=60000
jdbc.testOnBorrow=false
jdbc.testOnReturn=false
jdbc.testWhileIdle=true
jdbc.timeBetweenEvictionRunsMillis=60000
jdbc.numTestsPerEvictionRun=1800000
jdbc.minEvictableIdleTimeMillis=300000
jdbc.connectionInitSqls=
jdbc.exceptionSorter=
jdbc.filters=filter:wall
jdbc.removeAbandoned=true
jdbc.removeAbandonedTimeout=300
jdbc.logAbandoned=false
|
常用数据库validationQuery检查语句
数据库 |
validationQuery |
Oracle |
select 1 from dual |
MySQL |
select 1 |
DB2 |
select 1 from sysibm.sysdummy1 |
MS SQL Server |
select 1 |
HSQLDB |
select 1 from INFORMATION_SCHEMA.SYSTEM_USERS |
PostgreSQL |
select version() |
Derby |
select 1 |
H2 |
select 1 |