当前位置:网站首页>mysql advanced (twenty-four) method summary of defense against SQL injection
mysql advanced (twenty-four) method summary of defense against SQL injection
2022-08-03 11:40:00 【InfoQ】
一、前言
二、Demonstrate the classicSQL注入

select id,no from user where id=2;String sql = "select id,no from user where id=" + id;select id,no from user where id=2 or 1=1;
三、sql注入的原因
String sql = "select id,no from user where id=" + id; or 1=1 where id= 四、sql注入的防御
String sql = "select id, no from user where id=?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setInt(1, id);
ps.executeQuery();PreparedStatementselect id, no from user where id=? select ,from ,where ,and, or ,order by String sql = "select id,no from user where id=" + id; MySQLCodec codec = new MySQLCodec(Mode.STANDARD);
name = ESAPI.encoder().encodeForSQL(codec, name);
String sql = "select id,no from user where name=" + name;
ESAPI.encoder().encodeForSQL(codec, name)五、总结
ibatis,mybatis,hibernateibatis/mybatis#{name}${name}边栏推荐
猜你喜欢

html+css+php+mysql实现注册+登录+修改密码(附完整代码)

本周四晚19:00知识赋能第4期直播丨OpenHarmony智能家居项目之设备控制实现

FR9811S6 SOT-23-6 23V, 2A Synchronous Step-Down DC/DC Converter

MySQL database combat (1)

【倒计时5天】探索音画质量提升背后的秘密,千元大礼等你来拿

性能优化|从ping延时看CPU电源管理
【一起学Rust】Rust包管理工具Cargo初步了解

html网页如何获取后台数据库的数据(html + ajax + php + mysql)

实至名归!九章云极DataCanvas公司荣获智能制造领域多项殊荣

App自动化测试怎么做?实战分享App自动化测试全流程
随机推荐
ThreadLocal源码解析及使用场景
VRRP协议的作用及VRRP+OSPF配置方法
asdn涨薪技术之apifox+Jenkins如何玩转接口自动化测试
谷歌研究员被群嘲:研究员爆料AI有意识,被勒令休假
实至名归!九章云极DataCanvas公司荣获智能制造领域多项殊荣
RTP协议分析
Skills required to be a good architect: How to draw a system architecture that everyone will love?What's the secret?Come and open this article to see it!...
一个扛住 100 亿次请求的红包系统,写得太好了!!
赛灵思MPSOC裸机下的 USB调试实验
[Detailed explanation of binary search plus recursive writing method] with all the code
笔试题:金额拆分
MySQL之json数据操作
面试突击71:GET 和 POST 有什么区别?
viewstub 的详细用法_pageinfo用法
GET 和 POST 有什么区别?
微信小程序获取手机号
基于Sikuli GUI图像识别框架的PC客户端自动化测试实践
bash if条件判断
LeetCode——1161. 最大层内元素和
Vs 快捷键---探索不一样的编程