static public String safeSqlQueryIdentifier ( String in ) throws Exception { if ( null == in ) { throw new Exception ( "Null string passed as identifier" ) ; } if ( in . indexOf ( ' ' ) >= 0 ) { throw new Exception ( "Null character found in identifier" ) ; } // All quotes should be escaped in = in . replace ( "\"" , "\"\"" ) ; in = "\"" + in + "\"" ; return in ; }
This method converts a string into a new one that is safe for a SQL query . It deals with strings that are supposed to be identifiers .