If an invalid validationQuery is specified, the SQL Exception is logged at the DEBUG log level. Example: 2011-01-25 18:32:56,139 DEBUG [org.apache.tomcat.jdbc.pool.PooledConnection] Unable to validate object: com.ibm.db2.jcc.c.SqlException: DB2 SQL error: SQLCODE: -104, SQLSTATE: 42601, SQLERRMC: END-OF-STATEMENT;SELECT 1;<table_expr> Since an invalid validationQuery can cause problems with the data source, it would be nice to see this message logged at a different log level, such as WARN or ERROR. If that would create too much noise then I would suggest instead to add a check during the initialization of the data source that would test the validation query. Then this single check could log at WARN or ERROR. Thanks Dan
hi Dan, this is a tricky one. Cause, we'd also be logging a lot of false positive. Connections that have gone stale and simply need to be reconnected. So WARN log level would not be good in that case. However, I agree that initially you would want to know that the query is invalid.
Created attachment 26553 [details] proposed interceptor
What about adding an Interceptor to do the validation? The attached interceptor would take the validation query and run it when the pool is created. If there is a problem with the query it would report just that one time. Dan
If the connection to the database fails here, the interceptor will print out validationQuery has failed. and that is not correct I think the pool itself needs to do some validations upon startup 1. validation query 2. transaction isolation level 3. schema/catalog 4. default read only this is a valid bug, just needs to encompass the correct solution best Filip
(In reply to comment #3) > What about adding an Interceptor to do the validation? The attached > interceptor would take the validation query and run it when the pool is > created. If there is a problem with the query it would report just that one > time. > > Dan I'll add in logging when the pool starts. Right now, if initializing the pool fails, it sends a JMX notification but doesn't log anything. looking in the code it does if (log.isDebugEnabled()) log.debug("Unable to validate object:",ignore); So that should already be taken care of