org.apache.tomcat.dbcp.dbcp

## Class AbandonedConfig

- java.lang.Object
- - org.apache.tomcat.dbcp.dbcp.AbandonedConfig

-     public class AbandonedConfig
      extends java.lang.Object

  Configuration settings for handling abandoned db connections.
  Author:
    Glenn L. Nielsen

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbandonedConfig()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `getLogAbandoned()` Flag to log stack traces for application code which abandoned a Statement or Connection.
    `java.io.PrintWriter` | `getLogWriter()` Returns the log writer being used by this configuration to log information on abandoned objects.
    `boolean` | `getRemoveAbandoned()` Flag to remove abandoned connections if they exceed the removeAbandonedTimeout.
    `int` | `getRemoveAbandonedTimeout()` Timeout in seconds before an abandoned connection can be removed.
    `void` | `setLogAbandoned(boolean logAbandoned)` Flag to log stack traces for application code which abandoned a Statement or Connection.
    `void` | `setLogWriter(java.io.PrintWriter logWriter)` Sets the log writer to be used by this configuration to log information on abandoned objects.
    `void` | `setRemoveAbandoned(boolean removeAbandoned)` Flag to remove abandoned connections if they exceed the removeAbandonedTimeout.
    `void` | `setRemoveAbandonedTimeout(int removeAbandonedTimeout)` Sets the timeout in seconds before an abandoned connection can be removed.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### AbandonedConfig

          public AbandonedConfig()

  - ### Method Detail

    - #### getRemoveAbandoned

          public boolean getRemoveAbandoned()

      Flag to remove abandoned connections if they exceed the removeAbandonedTimeout.

      The default value is false.

      If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the `removeAbandonedTimeout`.

      Returns:
        true if abandoned connections are to be removed

    - #### setRemoveAbandoned

          public void setRemoveAbandoned(boolean removeAbandoned)

      Flag to remove abandoned connections if they exceed the removeAbandonedTimeout.

      If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the `removeAbandonedTimeout`.

      Parameters:
        `removeAbandoned` - true means abandoned connections will be removed
      See Also:
        `getRemoveAbandoned()`

    - #### getRemoveAbandonedTimeout

          public int getRemoveAbandonedTimeout()

      Timeout in seconds before an abandoned connection can be removed.

      Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one of the execute methods) resets the lastUsed property of the parent connection.

      Abandoned connection cleanup happens when

      - `removeAbandoned` == true
      - `numIdle` < 2
      - `numActive` > `maxActive` - 3

      The default value is 300 seconds.

    - #### setRemoveAbandonedTimeout

          public void setRemoveAbandonedTimeout(int removeAbandonedTimeout)

      Sets the timeout in seconds before an abandoned connection can be removed.

      Setting this property has no effect if `removeAbandoned` is false.

      Parameters:
        `removeAbandonedTimeout` - new abandoned timeout in seconds
      See Also:
        `getRemoveAbandonedTimeout()`, `getRemoveAbandoned()`

    - #### getLogAbandoned

          public boolean getLogAbandoned()

      Flag to log stack traces for application code which abandoned a Statement or Connection. Defaults to false. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.
      Returns:
        boolean true if stack trace logging is turned on for abandoned Statements or Connections

    - #### setLogAbandoned

          public void setLogAbandoned(boolean logAbandoned)

      Flag to log stack traces for application code which abandoned a Statement or Connection. Defaults to false. Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because a stack trace has to be generated.
      Parameters:
        `logAbandoned` - true turns on abandoned stack trace logging

    - #### getLogWriter

          public java.io.PrintWriter getLogWriter()

      Returns the log writer being used by this configuration to log information on abandoned objects. If not set, a PrintWriter based on System.out is used.
      Returns:
        log writer in use

    - #### setLogWriter

          public void setLogWriter(java.io.PrintWriter logWriter)

      Sets the log writer to be used by this configuration to log information on abandoned objects.
      Parameters:
        `logWriter` - The new log writer

Copyright © 2000-2020 Apache Software Foundation. All Rights Reserved.