java转义oracle数据库的通配查询符
2012-07-03 07:53:42 来源:WEB开发网核心提示:/** * Description: 处理转义字符%和_,针对ORACLE数据库 * @param str * @return */public static String escapeStr(String str){if(str.startsWith("%") || str.startsWith(
/**
* Description: 处理转义字符%和_,针对ORACLE数据库
* @param str
* @return
*/
public static String escapeStr(String str){
if(str.startsWith("%") || str.startsWith("_")){
str = "\\" + str;
}
if(str.endsWith("_")){
int index = str.indexOf("_");
str = str.substring(0, index) + "\\" + "_";
}
if(str.endsWith("%")){
int index = str.indexOf("%");
str = str.substring(0, index) + "\\" + "%";
}
return str;
}
更多精彩
赞助商链接
