diff --git a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java index 77efb61aa..61bd746be 100755 --- a/src/main/java/com/zaxxer/hikari/pool/PoolBase.java +++ b/src/main/java/com/zaxxer/hikari/pool/PoolBase.java @@ -143,28 +143,30 @@ boolean isConnectionAlive(final Connection connection) { try { try { + setNetworkTimeout(connection, validationTimeout); + + final long validationSeconds = (int) Math.max(1000L, validationTimeout) / 1000; + if (isUseJdbc4Validation) { - return connection.isValid((int) MILLISECONDS.toSeconds(Math.max(1000L, validationTimeout))); + return connection.isValid((int) validationSeconds); } - setNetworkTimeout(connection, validationTimeout); - try (Statement statement = connection.createStatement()) { if (isNetworkTimeoutSupported != TRUE) { - setQueryTimeout(statement, (int) MILLISECONDS.toSeconds(Math.max(1000L, validationTimeout))); + setQueryTimeout(statement, (int) validationSeconds); } statement.execute(config.getConnectionTestQuery()); } } finally { + setNetworkTimeout(connection, networkTimeout); + if (isIsolateInternalQueries && !isAutoCommit) { connection.rollback(); } } - setNetworkTimeout(connection, networkTimeout); - return true; } catch (Exception e) {