- 在配置时,主要有:removeAbandoned 、logAbandoned、removeAbandonedTimeout、maxWait这四个参数:
1. rmoveAbandoned=true 那么在getNumActive()快要到getMaxActive()的时候,系统会进行无效的Connection的回收,回收的Connection为removeAbandonedTimeout(默认300秒)中设置的秒数后没有使用的Connection,激活回收机制是getNumActive()=getMaxActive()-2。
2. logAbandoned=true的话,将会在回收事件后,在log中打印出回收Connection的错误信息,包括在哪个地方用 了Connection却忘记关闭了,在调试的时候很有用。
3. maxWait的时间不要设得太长,maxWait如果设置太长那么客户端会等待很久才激发回收事件。
以下是配置properties文件:
#连接设置
jdbc.driverClassName=oracle.jdbc.driver.OracleDriver