预处理prepareStatement是怎么防止sql注入漏洞的
1
select * from A where tablename.id = ?
传入参数'1;select * from B'如果不经过prepareStatement,会形成下面语句:
1
select * from A where tablename.id = 1;select * from B
这样等于两次执行,但如果经过预处理,会是这样:
1
select * from A where tablename.id = '1;select * from B'
'1;select * from B'只是一个参数,不会改变原来的语法