Uploaded image for project: 'Commons DBCP'
  1. Commons DBCP
  2. DBCP-71

[dbcp] Docs inaccurately describe default value of testOnBorrow

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • None
    • None
    • Operating System: other
      Platform: Other

    • 36799

    Description

      On the page http://jakarta.apache.org/commons/dbcp/configuration.html, the
      Default column for the testOnBorrow parameter says that testOnBorrow is set by
      default to "true". I observe from the behaviour of my application that this
      seems to be true only if validationQuery is not set to null. Further, I find
      this code in the BasicDataSource.java file, createDataSource method:
      // Can't test without a validationQuery
      if (validationQuery == null)

      { setTestOnBorrow(false); setTestOnReturn(false); setTestWhileIdle(false); }

      Users may think that DBCP uses a default validationQuery such as "SELECT 1" if
      you don't set one up explicitly, and that therefore setting testOnBorrow
      without setting validationQuery is legitimate. This is what I naively thought -
      although on reflection I can see why you don't, for reasons of portability.

      It would be very helpful if the documentation explained this, with text like
      this:
      "The testOnBorrow, testOnReturn, and testWhileIdle parameters are defaulted to
      true if and only if you supply a non-null value for the validationQuery
      parameter."

      It would be even more helpful if BasicDataSource noticed that testOnBorrow was
      set to true without a valid validationQuery setting, and logged something like
      "Disabling testOnBorrow, testOnReturn, and testWhileIdle because no
      valiationQuery was supplied. To enable these settings you must also supply a
      validationQuery, typically a very simple query like 'SELECT 1'".

      Attachments

        Activity

          People

            Unassigned Unassigned
            douglas.squirrel@youdevise.com Douglas Squirrel
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: