PreparedStatement如何避免或防止SQL注入?我知道PreparedStatements避免/防止SQL注入。它是怎么做到的?使用PreparedStatement构建的最终表单查询是否为字符串?
3 回答
芜湖不芜
TA贡献1796条经验 获得超7个赞
牧羊人nacy
TA贡献1862条经验 获得超7个赞
PreparedStatement stmt = conn.createStatement("INSERT INTO students VALUES('" + user + "')");stmt.execute();
PreparedStatement stmt = conn.prepareStatement("INSERT INTO student VALUES(?)");stmt.setString(1, user);stmt.execute();
Robert'); DROP TABLE students; --
添加回答
举报
0/150
提交
取消