Rewriting the query to use a PreparedStatement (parameterized query) keeps user data separate from the SQL command. The database engine treats bound values strictly as data, so characters such as quotes, semicolons, or comment markers cannot alter query structure, effectively eliminating SQL injection. Replacing quotes with a simple replace() can be bypassed with alternate encodings, alphanumeric whitelisting reduces-but does not eliminate-the attack surface, and encrypting the table or transport only protects confidentiality, not query integrity.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What are parameter-based queries?
Open an interactive chat with Bash
How do SQL injection attacks work?
Open an interactive chat with Bash
Why is encrypting data during transport with FTP not a sufficient defense?