我想知道以下异常意味着什么。当我设置testOnBorrow = ture时,我得到了这个。如果我设置testOnBorrow = false,我将不会得到它。
我正在使用MySQL 5.1.66和commons-pool-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
答案 1 :(得分: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)