Interface Validator
-
Method Summary
Modifier and TypeMethodDescriptionbooleanvalidate(Connection connection, int validateAction) Validate a connection and return a boolean to indicate if it's valid.
-
Method Details
-
validate
Validate a connection and return a boolean to indicate if it's valid.The pool calls this method with the underlying JDBC connection, outside any interceptor chain, and treats any runtime exception thrown by an implementation as a validation failure. Implementations that invoke JDBC APIs must catch
SQLExceptionand returnfalsethemselves, since this method does not declare a checked exception. Afalseresult (or a thrown runtime exception) causes the pool to discard the connection.The pool may skip validation entirely for a given action - it only validates when the corresponding
testOnBorrow,testOnReturn,testWhileIdleortestOnConnectflag is set - and it may short-circuit repeated validations, seePoolConfiguration.setValidationInterval(long). This method is therefore not guaranteed to run for every borrow, and it must not be relied on for per-borrow session state. Implementations are invoked concurrently from borrowing and returning application threads and from the pool cleaner thread and must be thread-safe.- Parameters:
connection- the underlying (non-proxied)Connectionobject to testvalidateAction- the action used. One ofPooledConnection.VALIDATE_BORROW,PooledConnection.VALIDATE_IDLE,PooledConnection.VALIDATE_INITorPooledConnection.VALIDATE_RETURN- Returns:
- true if the connection is valid
-