现在,将dropwizard与JDBI一起使用,如果断开了数据库连接并恢复了该连接,则此后请求将不再起作用。
我的数据库配置是:
database:
driverClass: org.postgresql.Driver
user: ${USER}
password: ${PASSWORD}
url: ${URL}
properties:
charSet: ${CHARSET:-UTF-8}
maxWaitForConnection: ${MAX_WAIT_FOR_CONNECTION:-1s}
validationQuery: ${VALIDATION_QUERY:-"SELECT 1"}
validationQueryTimeout: ${VALIDATION_QUERY_TIMEOUT:-3s}
initialSize: ${INITIAL_SIZE:-8}
minSize: ${MIN_SIZE:-8}
maxSize: ${MAX_SIZE:-32}
checkConnectionWhileIdle: ${CHECK_CONNECTION_WHILE_IDLE:-false}
evictionInterval: ${EVICTION_INTERVAL:-10s}
minIdleTime: ${MIN_IDLE_TIME:-10s}
removeAbandoned: ${REMOVE_ABANDONNED:-true}
removeAbandonedTimeout: ${REMOVE_ABANDONNED_TIMEOUT:-10s}
我注意到,如果initialSize = minSize = maxSize = 1,则恢复了连接,但是我需要更多连接。
感谢!
答案 0 :(得分:1)
添加配置 checkConnectionOnBorrow:是 每次从池中借用对象并重新连接到数据库时,这将验证连接