Commons Dbcp
  1. Commons Dbcp
  2. DBCP-263

Use a queryTimeout for the validationQuery in PoolableConnectionFactory

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Duplicate
    • Affects Version/s: 1.2, 1.2.1, 1.2.2
    • Fix Version/s: 1.3
    • Labels:
      None

      Description

      PoolableConnectionFactory.validateConnection(Connection conn) should use java.sql.Statement.setQueryTimeout(int) to avoid network problems and inappropriate validation queries. The timeout should either be a sensible default (say 5 secs) or be configurable.

      Links:

        Issue Links

          Activity

          Hide
          Phil Steitz added a comment -

          This issue duplicates DBCP-226

          Show
          Phil Steitz added a comment - This issue duplicates DBCP-226
          Hide
          Gerhard Kersten added a comment -

          Unfortunately java.sql.Statement.setQueryTimeout(int) will not help against hanging TCP connections, as already the Connection.createStatement() blocks. For the same problem in iBatis and a proposal using a separate watchdog thread see http://issues.apache.org/jira/browse/IBATIS-449

          Show
          Gerhard Kersten added a comment - Unfortunately java.sql.Statement.setQueryTimeout(int) will not help against hanging TCP connections, as already the Connection.createStatement() blocks. For the same problem in iBatis and a proposal using a separate watchdog thread see http://issues.apache.org/jira/browse/IBATIS-449
          Hide
          Christoph Grothaus added a comment -

          Here's the patch. To be applied on the "trunk" folder of DBCP. Sets the query timeout of the validation query to a fix value of 5 seconds.

          Show
          Christoph Grothaus added a comment - Here's the patch. To be applied on the "trunk" folder of DBCP. Sets the query timeout of the validation query to a fix value of 5 seconds.
          Hide
          Henri Yandell added a comment - - edited

          Seems like a good idea. Patches welcome

          Show
          Henri Yandell added a comment - - edited Seems like a good idea. Patches welcome
          Hide
          Gerhard Kersten added a comment -

          For us it's the same, and it's really mission-critical.

          Background: A firewall cuts a TCP connection after some time, but does not close it. With "validationQuery" dbcp waits forever for the validation query, making this feature completely useless.

          For a proposal see: http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg92474.html

          Show
          Gerhard Kersten added a comment - For us it's the same, and it's really mission-critical. Background: A firewall cuts a TCP connection after some time, but does not close it. With "validationQuery" dbcp waits forever for the validation query, making this feature completely useless. For a proposal see: http://www.mail-archive.com/commons-dev@jakarta.apache.org/msg92474.html

            People

            • Assignee:
              Unassigned
              Reporter:
              Christoph Grothaus
            • Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 0.5h
                0.5h
                Remaining:
                Remaining Estimate - 0.5h
                0.5h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development