Class QueryTimeout

java.lang.Object
com.mcpdbwizard.pub.QueryTimeout

public final class QueryTimeout extends Object
An optional cap on how long any one generated statement may run.

Set DAO_QUERY_TIMEOUT_SECONDS (or -Ddao.query.timeoutSeconds). Unset means no cap, which is the behaviour every existing deployment already has.

Why this matters more than a rate limit

A rate limit bounds how often work starts. It does nothing about how long one call runs, and a single expensive query holds its pooled factory — and therefore its Oracle session — for as long as the database takes. A handful of slow calls can starve every other caller at trivial request rates. This is the control that bounds that, and it is why docs/mcp-rate-limiting-plan.md rates it above the rate limit itself.

It is opt-in on purpose. A timeout low enough to be useful against a runaway query is also low enough to break a legitimately slow report, and only the deployment knows which of its statements are which. Defaulting this on would trade a rare failure for a routine one.

Oracle raises ORA-01013 when the cap is hit, which the generated code surfaces as an ordinary CSException — the call fails, the factory returns to the pool, and the session is reusable. Copyright 2003-2026 ATB Consultancy Services Ltd (formerly Orinda Software Ltd, Dublin, Ireland)

  • Field Details

    • ENVIRONMENT_VARIABLE

      public static final String ENVIRONMENT_VARIABLE
      Environment variable holding the cap in seconds.
      See Also:
    • SYSTEM_PROPERTY

      public static final String SYSTEM_PROPERTY
      System property equivalent, which wins over the environment.
      See Also:
  • Method Details

    • getSeconds

      public static int getSeconds()
      The configured cap in seconds, or 0 when there is none.
    • isEnabled

      public static boolean isEnabled()
    • apply

      public static void apply(Statement theStatement)
      Apply the cap to a statement, if one is configured.

      Deliberately swallows SQLException: a driver that will not accept a query timeout is not a reason to fail the call the statement was prepared for. The cap is a safety net, and a safety net that breaks the thing it protects is worse than none.

      Parameters:
      theStatement - the statement just prepared; null is tolerated