- --all 用$不能防sql注入
- select * from user where name like '%${name}%'
- --mysql,oracle (db2的concat函数只支持2个参数)
- select * from user where name like concat('%',#{name},'%')
- --oracle,db2
- select * from user where name like '%'||#{name}||'%'
- --SQL Server
- select * from user where name like '%'+#{name}+'%'
- --据说这种是预编译,有空测下
- select * from user where name like "%"#{name}"%"
转自:http://happyqing.iteye.com/blog/2172397
本文介绍了在不同数据库系统中如何通过正确使用SQL语句来避免SQL注入攻击的方法。包括使用预编译语句和字符串拼接的方式,并针对MySQL、Oracle、DB2及SQL Server等给出了具体的实现示例。
3731

被折叠的 条评论
为什么被折叠?



