Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7967187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:37:42+00:00 2026-06-04T06:37:42+00:00

I use DBCP pool and I want use testOnBorrow and testOnReturn to test if

  • 0

I use DBCP pool and I want use testOnBorrow and testOnReturn to test if connection is still valid.
Unfortunately I have to set property validationQuery to make it work.

Question: What value should be in validationQuery?

I know, that: validationQuery must be an SQL SELECT statement, that returns at least one row.

Problem is that we use various databases (DB2, Oracle, hsqldb).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:37:43+00:00Added an answer on June 4, 2026 at 6:37 am

    There is not only one validationQuery for all databases. On each database you have to use different validationQuery.

    After few hours of googling and testing I have collected this table:

    Database validationQuery notes

    • hsqldb – select 1 from INFORMATION_SCHEMA.SYSTEM_USERS
    • Oracle – select 1 from dual
    • DB2 – select 1 from sysibm.sysdummy1
    • mysql – /* ping */ select 1
    • microsoft SQL Server – select 1 (tested on SQL-Server 9.0, 10.5 [2008])
    • postgresql – select 1
    • ingres – select 1
    • derby – values 1
    • H2 – select 1
    • Firebird – select 1 from rdb$database
    • MariaDb – select 1
    • Informix – select 1 from systables
    • Hive – select 1
    • Impala – select 1

    I wrote about it on my blog – validation query for various databases.

    In advance there is an example of class, which return validationQuery according to JDBC driver.

    Or does anybody have better solution?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I try to get Tomcat to use BoneCP as a connection pool because DBCP
This article suggests Tomcat 7 apps should use a JDBC connection pool instead of
I am using Apache DBCP to get a pool of connections, I use PoolingDataSource
I want to use commons DBCP in my web application. I am using java
i currently build an application use spring as framework. and i want to test
I'm using JMetric to test my DBCP pool. Using one test with 20 threads
I have a java application that uses jtds driver and commons-dbcp as a connection
Use case: I've just entered insert mode, and typed some text. Now I want
In an application I want to use my own implementation of javax.sql.DataSource that extends
I have a multi module maven web application, which uses hibernate. I use the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.