wiki.xsx.jg.util.StrUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of JG-All Show documentation
Show all versions of JG-All Show documentation
a generator, from the database tables convert to the Java classes or from the Java classes convert to the database tables.
support mysql, oracle and sqlserver.
package wiki.xsx.jg.util;
/**
* 字符串工具
*/
public class StrUtil {
/**
* 将Java字符串转换为数据库中的字符串
* @param str Java字符串
* @return 数据库中的字符串
*/
public static String toSQLString(String str){
StringBuilder builder = new StringBuilder();
if (str!=null){
String strs[] = str.split(",");
for (String s : strs){
builder.append("'").append(s).append("',");
}
return builder.substring(0, builder.length()-1);
}else{
builder.append("'").append(str).append("'");
return builder.toString();
}
}
}