code: private PreparedStatement checkValidity(PreparedStatement ps, String key) {
          long currentTime = currentTimeMillis();
          Long lastChecked = threadedPsTimeMap.get().get(key);
          if (lastChecked == null) {
              // if never checked, setting to 0 ensures check will occur
              // (as long as we're not less than 10min past 1 Jan 1970)
              lastChecked = 0L;
          }
          if (currentTime - lastChecked.longValue() > VALIDITY_CHECK_INTERVAL) {
              try {
                  Connection psConn = ps.getConnection();
                  if (psConn == null || psConn.isClosed()
                          || !psConn.isValid(VALIDITY_TIMEOUT)) {
                      logger.info("Connection for PreparedStatement is closed or "
                              + "invalid; removing from cache");
                      // remove the prepared statement w/ invalid connection
                      threadedPsMap.get().remove(key);
                      ps = null;
                  }
              } catch (SQLException e) {
                  logger.info("Failed to check Prepared Statement validity.", e);
                  ps = null;
              }
          }
          return ps;
      }
docs: Validate the {@link Connection} backing a {@link PreparedStatement}.
  
  @param ps
  @param key
  @return the provided {@link PreparedStatement} if valid,
  <code>null</code> if the statement's {@link Connection} was
  invalid.