code: public boolean isConnectionError(SQLException ex) {
          final boolean isTraceOn = TraceComponent.isAnyTracingEnabled();
  
          if (isTraceOn && tc.isEntryEnabled())
              Tr.entry(this, tc, "isConnectionError", ex);
  
          // Maintain a set in order to check for cycles
          Set<Throwable> chain = new HashSet<Throwable>();
  
          boolean stale = super.isConnectionError(ex);
          for (Throwable t = ex; t != null && !stale && chain.add(t); t = t.getCause()) {
              SQLException sqlX = t instanceof SQLException ? (SQLException) t : null;
              if (isTraceOn && tc.isDebugEnabled())
                  Tr.debug(this, tc, "checking " + t,
                           sqlX == null ? null : sqlX.getSQLState(),
                           sqlX == null ? null : sqlX.getErrorCode());
              if (sqlX != null)
                  stale |= isDataDirectExp(ex)
                           ? staleDDErrorCodes.contains(sqlX.getErrorCode()) || staleDDSQLStates.contains(sqlX.getSQLState())
                           : staleMSErrorCodes.contains(sqlX.getErrorCode());
          }
  
          if (isTraceOn && tc.isEntryEnabled())
              Tr.exit(this, tc, "isConnectionError", stale);
  
          return stale;
      }
docs: This method determines whether a <code>SQLException</code> indicates a stale connection error.
  
  @param ex the <code>SQLException</code> to check.
  @return true if the exception indicates a stale connection error, otherwise false.