I recently learned not using the .set() methods of PreparedStatements is a pretty huge security flaw.
After looking at some code examples I have a few questions regarding PreparedStatements and their security.
If someone can attack a MySQL query to change the data, how exactly does the PreparedStatement's .set() methods prevent an attack?
For example, if the query is
INSERT INTO table_name(?, ?);
(Assuming both of the question marks will be strings)
Couldn't someone simply change the table_name to another table?
Another example; If the query is
UPDATE table_name SET column_name=?;
Couldn't a person change the column_name to make the query change a differnet column?
Final example I could think of; If the query is
SELECT column_name FROM table_name WHERE column2_name = ?;
Would it be possible for an attacker to modify the column_name, table_name, etc. Or inject other actions into the query?
As you can probably tell, I don't know much about security and MySQL, so excuse me if these are extremely obvious questions. Thank you!