From 21d406b052308dff64fe778161643071eef9418a Mon Sep 17 00:00:00 2001 From: Gert-Jan Paulissen Date: Wed, 3 Jul 2024 15:28:22 +0200 Subject: [PATCH] Update PoolDataSourceStatistics.java --- .../pato/jdbc/PoolDataSourceStatistics.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/jdbc/smart-pool-data-source/src/main/java/com/paulissoft/pato/jdbc/PoolDataSourceStatistics.java b/jdbc/smart-pool-data-source/src/main/java/com/paulissoft/pato/jdbc/PoolDataSourceStatistics.java index f61d5d43..dd3059a3 100644 --- a/jdbc/smart-pool-data-source/src/main/java/com/paulissoft/pato/jdbc/PoolDataSourceStatistics.java +++ b/jdbc/smart-pool-data-source/src/main/java/com/paulissoft/pato/jdbc/PoolDataSourceStatistics.java @@ -513,16 +513,18 @@ void signalSQLException(final SimplePoolDataSource pds, final SQLException ex) { try { if (pds != null && ex != null) { final long nrOccurrences = signalSQLException(ex); - - // show the message - logger.error("getConnection() raised occurrence # {} for this SQL exception: class={}, error code={}, SQL state={}. " + - "Pool: {}, error message: {}", - nrOccurrences, - ex.getClass().getSimpleName(), - ex.getErrorCode(), - ex.getSQLState(), // may be null - pds.getPoolName(), - ex.getMessage()); + + if (nrOccurrences > 0L) { + // show the message + logger.error("getConnection() raised occurrence # {} for this SQL exception: class={}, error code={}, SQL state={}. " + + "Pool: {}, error message: {}", + nrOccurrences, + ex.getClass().getSimpleName(), + ex.getErrorCode(), + ex.getSQLState(), // may be null + pds.getPoolName(), + ex.getMessage()); + } } } catch (Exception e) { logger.error("Exception in signalSQLException():", e); @@ -555,12 +557,14 @@ void signalException(final SimplePoolDataSource pds, final Exception ex) { if (pds != null && ex != null) { final long nrOccurrences = signalException(ex); - // show the message - logger.error("getConnection() raised occurrence # {} for this exception: class={}. Pool: {}, error message: {}", - nrOccurrences, - ex.getClass().getSimpleName(), - pds.getPoolName(), - ex.getMessage()); + if (nrOccurrences > 0L) { + // show the message + logger.error("getConnection() raised occurrence # {} for this exception: class={}. Pool: {}, error message: {}", + nrOccurrences, + ex.getClass().getSimpleName(), + pds.getPoolName(), + ex.getMessage()); + } } } catch (Exception e) { logger.error("Exception in signalException():", e);