2012-12-07 81 views
1

我不知道以下例外的含義。當我設置testOnBorrow = ture時,我會得到這個。如果我設置testOnBorrow = false,我不會得到這個。java.util.NoSuchElementException:無法創建驗證對象,原因:ValidateObject失敗

我使用MySQL 66年5月1日和commons-池1.5.5.jar

Caused by: java.util.NoSuchElementException: Could not create a validated object, cause: ValidateObject failed at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1203) at org.apache.commons.dbcp.PoolingDriver.connect(PoolingDriver.java:180) ... 7 more

+0

請,張貼相關的代碼 –

回答

0

我覺得你輸錯true

您的代碼:

testOnBorrow=ture 

應該是:

testOnBorrow=true 
0

這是Tomcat的文件說,大約testOnBorrow ...

testOnBorrow:

(boolean) The indication of whether objects will be validated before being borrowed from the pool. 
If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another. 
NOTE - for a true value to have any effect, the validationQuery or validatorClassName parameter must be set to a non-null string. 
In order to have a more efficient validation, see validationInterval. 
Default value is false 

validationQuery :

(String) The SQL query that will be used to validate connections from this pool before returning them to the caller. 
If specified, this query does not have to return any data, it just can't throw a SQLException. 
The default value is null. 
Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server) 

https://tomcat.apache.org/tomcat-7.0-doc/jdbc-pool.html

相關問題