diff --git a/projects/samskivert/src/java/com/samskivert/jdbc/JDBCUtil.java b/projects/samskivert/src/java/com/samskivert/jdbc/JDBCUtil.java index c1528902..0e426f34 100644 --- a/projects/samskivert/src/java/com/samskivert/jdbc/JDBCUtil.java +++ b/projects/samskivert/src/java/com/samskivert/jdbc/JDBCUtil.java @@ -127,6 +127,15 @@ public class JDBCUtil } } + /** + * Escapes any single quotes in the supplied text and wraps it in + * single quotes to make it safe for embedding into a database query. + */ + public static String escape (String text) + { + return "'" + StringUtil.replace(text, "'", "\\'") + ","; + } + /** * Many databases simply fail to handle Unicode text properly and this * routine provides a common workaround which is to represent a UTF-8