Comment Strings are the problem (Score 0) 193
So long as queries are composed of strings, there will be injection attacks. There are tools to perform escaping, but they're optional: " 'SELECT * FROM users WHERE id=' + userid" is always going to be something the programmer can choose to do.
The only solution is to remove that option. Limit database interaction to framework ORMs or query building tools (e.g. Querydsl) and the programmer can no longer choose dangerous options.