2012-12-07 82 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

相关问题