Package org.apache.tomcat.dbcp.dbcp2
Class Utils
java.lang.Object
org.apache.tomcat.dbcp.dbcp2.Utils
Utility methods.
- Since:
- 2.0
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringAny SQL_STATE starting with this value is considered a fatal disconnectDeprecated.static final booleanDeprecated.No replacement.
- 
Method SummaryModifier and TypeMethodDescriptionstatic char[]clone(char[] value) Clones the given char[] if not null.static PropertiescloneWithoutCredentials(Properties properties) Clones the givenPropertieswithout the standard "user" or "password" entries.static voidclose(AutoCloseable autoCloseable, Consumer<Exception> exceptionHandler) Closes the givenAutoCloseableand if an exception is caught, then callsexceptionHandler.static voidcloseQuietly(AutoCloseable autoCloseable) Closes the AutoCloseable (which may be null).static voidcloseQuietly(Connection connection) Deprecated.static voidcloseQuietly(ResultSet resultSet) Deprecated.static voidcloseQuietly(Statement statement) Deprecated.Gets a copy of SQL codes of fatal connection errors.static StringgetMessage(String key) Gets the correct i18n message for the given key.static StringgetMessage(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 StringtoString(char[] value) Converts the given char[] to a String.static voidvalidateLifetime(PooledObject<?> p, Duration maxDuration) 
- 
Field Details- 
IS_SECURITY_ENABLEDDeprecated.No replacement.Whether the security manager is enabled.
- 
DISCONNECTION_SQL_CODE_PREFIXAny SQL_STATE starting with this value is considered a fatal disconnect- See Also:
 
- 
DISCONNECTION_SQL_CODESDeprecated.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 Details- 
clonepublic static char[] clone(char[] value) Clones the given char[] if not null.- Parameters:
- value- may be null.
- Returns:
- a cloned char[] or null.
 
- 
cloneWithoutCredentialsClones the givenPropertieswithout the standard "user" or "password" entries.- Parameters:
- properties- may be null
- Returns:
- a clone of the input without the standard "user" or "password" entries.
- Since:
- 2.8.0
 
- 
closeCloses the givenAutoCloseableand if an exception is caught, then callsexceptionHandler.- Parameters:
- autoCloseable- The resource to close.
- exceptionHandler- Consumes exception thrown closing this resource.
- Since:
- 2.10.0
 
- 
closeQuietlyCloses the AutoCloseable (which may be null).- Parameters:
- autoCloseable- an AutoCloseable, may be- null
- Since:
- 2.6.0
 
- 
closeQuietlyDeprecated.Closes the Connection (which may be null).- Parameters:
- connection- a Connection, may be- null
 
- 
closeQuietlyDeprecated.Closes the ResultSet (which may be null).- Parameters:
- resultSet- a ResultSet, may be- null
 
- 
closeQuietlyDeprecated.Closes the Statement (which may be null).- Parameters:
- statement- a Statement, may be- null.
 
- 
getDisconnectionSqlCodesGets a copy of 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)
 - Returns:
- SQL codes of fatal connection errors.
- Since:
- 2.10.0
 
- 
getMessageGets the correct i18n message for the given key.- Parameters:
- key- The key to look up an i18n message.
- Returns:
- The i18n message.
 
- 
getMessageGets 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.
 
- 
toCharArrayConverts the given String to a char[].- Parameters:
- value- may be null.
- Returns:
- a char[] or null.
 
- 
toStringConverts the given char[] to a String.- Parameters:
- value- may be null.
- Returns:
- a String or null.
 
- 
validateLifetimepublic static void validateLifetime(PooledObject<?> p, Duration maxDuration) throws org.apache.tomcat.dbcp.dbcp2.LifetimeExceededException - Throws:
- org.apache.tomcat.dbcp.dbcp2.LifetimeExceededException
 
 
- 
getDisconnectionSqlCodes().