以上基于 Hibernate Annotations 3.4.0.GA和Hibernate 3.3.1.GA的研究
1. 当hibernate.properties 和hibernate.cfg.xml同时配置了c3p0的相关属性,则hibernate会使用在hibernate.cfg.xml中的属性
加载hibernate日志的时候又这样一句话:Both hibernate-style property 'hibernate.c3p0.idle_test_period' and c3p0-style
property 'hibernate.c3p0.idleConnectionTestPeriod' have been set in hibernate.properties. Hibernate-style property
'hibernate.c3p0.idle_test_period' will be used and c3p0-style property 'hibernate.c3p0.idleConnectionTestPeriod'
will be ignored!
意思就是hibernate.c3p0.idle_test_period 和hibernate.c3p0.idleConnectionTestPeriod同时配置了,将使用hibernate.c3p0.idle_test_period
acquireIncrement -> 2, 连接不够用时,每次增长2个
acquireRetryAttempts -> 30, 从数据库获取新连接失败后重复尝试的次数
acquireRetryDelay -> 1000, 两次连接获取中的间隔时间,单位毫秒
autoCommitOnClose -> false, 连接关闭时默认将所有未提交的操作回滚
automaticTestTable -> c3p0TestTable, c3p0将建一张名为c3p0TestTable的空表,并使用其自带的查询语句进行 测试。如果定义了这个参数那么属性preferredTestQuery将被忽略。
breakAfterAcquireFailure -> false, 获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常。但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭
checkoutTimeout -> 3000,