org.apache.commons.dbcp2

## Class Utils

- java.lang.Object
- - org.apache.commons.dbcp2.Utils

-     public final class Utils
      extends Object

  Utility methods.
  Since:
    2.0

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static String` | `DISCONNECTION_SQL_CODE_PREFIX` Any SQL_STATE starting with this value is considered a fatal disconnect
    `static Set<String>` | `DISCONNECTION_SQL_CODES` SQL codes of fatal connection errors.
    `static boolean` | `IS_SECURITY_ENABLED` Whether the security manager is enabled.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static void` | `closeQuietly(Connection connection)` Closes the Connection (which may be null).
    `static void` | `closeQuietly(ResultSet resultSet)` Closes the ResultSet (which may be null).
    `static void` | `closeQuietly(Statement statement)` Closes the Statement (which may be null).
    `static String` | `getMessage(String key)` Gets the correct i18n message for the given key.
    `static String` | `getMessage(String key, Object... args)` Gets the correct i18n message for the given key with placeholders replaced by the supplied arguments.
    `static char[]` | `toCharArray(String value)` Converts the given String to a char[].
    `static String` | `toString(char[] value)` Converts the given char[] to a String.

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

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

- - ### Field Detail

    - #### IS_SECURITY_ENABLED

          public static final boolean IS_SECURITY_ENABLED

      Whether the security manager is enabled.

    - #### DISCONNECTION_SQL_CODE_PREFIX

          public static final String DISCONNECTION_SQL_CODE_PREFIX

      Any SQL_STATE starting with this value is considered a fatal disconnect
      See Also:
        Constant Field Values

    - #### DISCONNECTION_SQL_CODES

          public static final Set<String> DISCONNECTION_SQL_CODES

      SQL codes of fatal connection errors.
      - 57P01 (ADMIN SHUTDOWN)
      - 57P02 (CRASH SHUTDOWN)
      - 57P03 (CANNOT CONNECT NOW)
      - 01002 (SQL92 disconnect error)
      - JZ0C0 (Sybase disconnect error)
      - JZ0C1 (Sybase disconnect error)

  - ### Method Detail

    - #### closeQuietly

          public static void closeQuietly(ResultSet resultSet)

      Closes the ResultSet (which may be null).
      Parameters:
        `resultSet` - a ResultSet, may be `null`

    - #### closeQuietly

          public static void closeQuietly(Connection connection)

      Closes the Connection (which may be null).
      Parameters:
        `connection` - a Connection, may be `null`

    - #### closeQuietly

          public static void closeQuietly(Statement statement)

      Closes the Statement (which may be null).
      Parameters:
        `statement` - a Statement, may be `null`.

    - #### getMessage

          public static String getMessage(String key)

      Gets the correct i18n message for the given key.
      Parameters:
        `key` - The key to look up an i18n message.
      Returns:
        The i18n message.

    - #### getMessage

          public static String getMessage(String key,
                                          Object... args)

      Gets the correct i18n message for the given key with placeholders replaced by the supplied arguments.
      Parameters:
        `key` - A message key.
        `args` - The message arguments.
      Returns:
        An i18n message.

    - #### toCharArray

          public static char[] toCharArray(String value)

      Converts the given String to a char[].
      Parameters:
        `value` - may be null.
      Returns:
        a char[] or null.

    - #### toString

          public static String toString(char[] value)

      Converts the given char[] to a String.
      Parameters:
        `value` - may be null.
      Returns:
        a String or null.

Copyright © 2001–2018 The Apache Software Foundation. All rights reserved.