What is a validationQuery with respect to databases and JNDI?

孤街浪徒 提交于 2019-11-29 14:22:21
rgettman

The validation query is a query run by the data source to validate that a Connection is still open before returning it. Here's Tomcat's definition of a validation query; scroll down to the middle of section "4. Configure Tomcat's Resource Factory", looking for the "validationQuery" attribute.

EDIT

According to this answer, if the validation query fails, no error is thrown; the bad/closed connection is dropped and another connection is created to replace it.

It has no relevance to JNDI, but JDBC datasources.

The validation query is used to validate connections from the datasource connection pool, before those are handed-off to the clients. Usually these are low impact query such as "SELECT 1..." or "SELECT SYSDATE..."

I assume it is a query to test if DB connection works fine. Some sort of ping on the app-server level.

In the original question periodic pinging of the DB keeps the connection opened.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!