在HIbernate 的配置文件中加入下面内容:
## DBCP Connection Pool
hibernate.dbcp.maxActive 100
hibernate.dbcp.whenExhaustedAction 1
hibernate.dbcp.maxWait 120000
hibernate.dbcp.maxIdle 10
## prepared statement cache
hibernate.dbcp.ps.maxActive 100
hibernate.dbcp.ps.whenExhaustedAction 1
hibernate.dbcp.ps.maxWait 120000
hibernate.dbcp.ps.maxIdle 100
## optional query to validate pooled connections:
hibernate.dbcp.validationQuery select 1 from dual
hibernate.dbcp.testOnBorrow true
hibernate.dbcp.testOnReturn false

本文介绍了如何在Hibernate配置文件中设置DBCP数据库连接池参数,包括最大活动连接数、空闲连接数、最大等待时间和连接验证策略等。通过详细解释各个参数的作用,确保高效、稳定的数据库连接管理。
最低0.47元/天 解锁文章

942





