当前位置:千优问>百科知识>ps.executeUpdate(); 是什么意思?

ps.executeUpdate(); 是什么意思?

2022-11-06 09:32:30 编辑:leo 浏览量:608

ps.executeUpdate(); 是什么意思?

是当成功插入数据到数据库时候,这个会返回一个大于1的数字,来表明数据成功插入库之中

sql注入发生的时间,sql注入发生的阶段在sql预编译阶段,当编译完成的sql不会产生sql注入,采用jdbc操作数据时候,preparedStatement 预编译对象会对传入sql进行预编译。

那么当传入id 字符串为 "update ft_proposal set id = 3;drop table ft_proposal;" 这种情况下就会导致sql注入删除ft_proposal这张表。

ps.executeUpdate(); 是什么意思?

预编译语句

处理使用预编译语句之外,另一种实现方式可以采用存储过程,存储过程其实也是预编译的,存储过程是sql语句的集合,将所有预编译的sql语句编译完成后,存储在数据库上。

当传入的参数为3;drop table user;当执行时可以看见打印的sql语句为:select name from usre where id = ?;不管输入何种参数时,都可以防止sql注入,因为mybatis底层实现了预编译。

标签:ps,executeUpdate