ibatis解决sql注入问题
2013-03-22 13:15
302 查看
对于ibaits参数引用可以使用#和$两种写法,其中#写法会采用预编译方式,将转义交给了数据库,不会出现注入问题;如果采用$写法,则相当于拼接字符串,会出现注入问题。
例如,如果属性值为“' or '1'='1 ”,采用#写法没有问题,采用$写法就会有问题。
对于like语句,难免要使用$写法,
1. 对于Oracle可以通过'%'||'#param#'||'%'避免;
2. 对于MySQL可以通过CONCAT('%',#param#,'%')避免;
3. MSSQL中通过'%'+#param#+'% 。
如下3种SQL语句:
[java] view
plaincopy
mysql: select * from t_user where name like concat('%',#name #,'%')
oracle: select * from t_user where name like '%'||#name #||'%'
SQL Server:select * from t_user where name like '%'+#name #+'%
例如,如果属性值为“' or '1'='1 ”,采用#写法没有问题,采用$写法就会有问题。
对于like语句,难免要使用$写法,
1. 对于Oracle可以通过'%'||'#param#'||'%'避免;
2. 对于MySQL可以通过CONCAT('%',#param#,'%')避免;
3. MSSQL中通过'%'+#param#+'% 。
如下3种SQL语句:
[java] view
plaincopy
mysql: select * from t_user where name like concat('%',#name #,'%')
oracle: select * from t_user where name like '%'||#name #||'%'
SQL Server:select * from t_user where name like '%'+#name #+'%
相关文章推荐
- iBatis解决sql注入问题的方法
- ibatis解决sql注入问题
- 通过ibatis解决sql注入问题
- ibatis解决sql注入问题
- ibatis解决sql注入问题
- ibatis解决sql注入问题
- (转载)ibatis:解决sql注入问题
- ibatis解决sql注入问题 .
- ibatis解决sql注入问题
- ibatis解决sql注入问题 .
- ibatis分组查询结果的返回参数绑定问题解决方案
- 解决IBatis中的多对一映射n+1问题
- 转:ibatis的N+1问题解决方案
- 解决ASP防SQL注入攻击程序问题
- 学习mybatis框架中遇到org.apache.ibatis.exceptions.PersistenceException: 问题解决
- 解决sql注入问题(丛林战争项目)
- JDBC解决sql注入问题
- 触发器解决SQL注入问题
- mybatis解决sql注入问题
- 关于网站SQL注入的问题,以及解决办法