All Downloads are FREE. Search and download functionalities are using the official Maven repository.

wiki.xsx.jg.util.StrUtil Maven / Gradle / Ivy

Go to download

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.

There is a newer version: 1.2.1
Show newest version
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();
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy