From f79e82002c10a8b69919538c6ed1fcc2fc2748a9 Mon Sep 17 00:00:00 2001 From: mdb Date: Wed, 8 Jun 2005 23:20:15 +0000 Subject: [PATCH] Would you believe, yet another convenience method? git-svn-id: https://samskivert.googlecode.com/svn/trunk@1655 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../src/java/com/samskivert/jdbc/JDBCUtil.java | 9 +++++++++ 1 file changed, 9 insertions(+) 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