Sep
2
String.replaceAll(String, String) wowes
Filed Under Software Development on September 2, 2005 | 9 Comments
When you are dealing with databases one of the most common things you have to do is to escape out all single quotes in text being entered into the DB to stop PostgreSQL/MySQL/*SQL having a cow and to prevent injection attacks.
In most languages this is trivial, take Perl for example
my $sqlText =~ s/'/\\'/g;
Could it be that easy in Java … not on your life!