List of usage examples for org.apache.commons.dbcp2 Utils DISCONNECTION_SQL_CODE_PREFIX
String DISCONNECTION_SQL_CODE_PREFIX
To view the source code for org.apache.commons.dbcp2 Utils DISCONNECTION_SQL_CODE_PREFIX.
Click Source Link
From source file:JDBCPool.dbcp.demo.sourcecode.PoolableConnection.java
/** * Checks the SQLState of the input exception and any nested SQLExceptions it wraps. * <p>//from w ww .j a v a 2 s.com * If {@link #getDisconnectSqlCodes() disconnectSQLCodes} has been set, sql states * are compared to those in the configured list of fatal exception codes. If this * property is not set, codes are compared against the default codes in * #{@link Utils.DISCONNECTION_SQL_CODES} and in this case anything starting with * #{link Utils.DISCONNECTION_SQL_CODE_PREFIX} is considered a disconnection.</p> * * @param e SQLException to be examined * @return true if the exception signals a disconnection */ private boolean isDisconnectionSqlException(SQLException e) { boolean fatalException = false; String sqlState = e.getSQLState(); if (sqlState != null) { fatalException = _disconnectionSqlCodes == null ? sqlState.startsWith(Utils.DISCONNECTION_SQL_CODE_PREFIX) || Utils.DISCONNECTION_SQL_CODES.contains(sqlState) : _disconnectionSqlCodes.contains(sqlState); if (!fatalException) { if (e.getNextException() != null) { fatalException = isDisconnectionSqlException(e.getNextException()); } } } return fatalException; }