为了防止SQL注入,iBatis模糊查询时也要避免使用$$来进行传值。下面是三个不同数据库的ibatis的模糊查询传值。
- mysql: select * from stu where name like concat('%',#name #,'%')
- oracle: select * from stu where name like '%'||#name #||'%'
- SQL Server:select * from stu where name like '%'+#name #+'%
smallyounger 博主文章分类:数据库
为了防止SQL注入,iBatis模糊查询时也要避免使用$$来进行传值。下面是三个不同数据库的ibatis的模糊查询传值。
- mysql: select * from stu where name like concat('%',#name #,'%')
- oracle: select * from stu where name like '%'||#name #||'%'
- SQL Server:select * from stu where name like '%'+#name #+'%
上一篇:学习开源框架WebX的总结
下一篇:Spring学习(一)依赖注入
对于ibaits参数引用可以使用#和$两种写法,其中#写法会采用预编译方式,将转义交给了数据库,不会出现注入问题;如果采用$写法,则相
a.name like #name# escape '`'
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M