code: public static String escapeSqlLikePattern(String pattern, char escapeChar) {
  
          char[] special = new char[] {escapeChar, '%', '_'};
          String result = pattern;
          for (char charToEscape : special) {
              result = result.replaceAll("" + charToEscape, "" + escapeChar + charToEscape);
          }
          return result;
      }
docs: Escapes the wildcard characters in a string which will be used as the pattern for a SQL LIKE clause.<p>
  
  @param pattern the pattern
  @param escapeChar the character which should be used as the escape character
  
  @return the escaped pattern