Replace the wildcard-character with defined charater for SQL queries


/ Published in: Java
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /**
  2.  * Replace the wildcard-character with defined charater for SQL queries
  3.  *
  4.  * @param var
  5.  * value to be checked and replaced with proper wildcard
  6.  *
  7.  * @return formatted String
  8.  */
  9. public static String processWildCard(String var) {
  10. final String WILDCARD = "*";
  11. final String ORWILDCARD = "%";
  12.  
  13. if (var.indexOf(WILDCARD) != -1) {
  14. System.out.println(">> found wildcard at index: " + var.indexOf(WILDCARD));
  15. var = org.springframework.util.StringUtils.replace(var, WILDCARD, ORWILDCARD);
  16.  
  17. return var.toUpperCase();
  18. } else {
  19. return var.toUpperCase();
  20. }
  21. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.